Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introspection functionality #12

Merged
merged 6 commits into from
Sep 25, 2017
Merged

Introspection functionality #12

merged 6 commits into from
Sep 25, 2017

Conversation

mkulikk
Copy link

@mkulikk mkulikk commented Sep 14, 2017

No description provided.

@@ -29,27 +29,52 @@ function CustomHandler:access(config)

session.configure(config)

local res, err = require("resty.openidc").authenticate(oidcConfig)
if tryIntrospect(oidcConfig) then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, update also README.md and explain "two legged authentication" usage maybe at "What is Kong OIDC plugin" section.

@phirvone
Copy link
Collaborator

You need to rename also kong-oidc-1.0.2-0.rockspec to kong-oidc-1.0.3-0.rockspec and update version = "1.0.2-0" --> "1.0.3-0" and tag = "v1.0.2" --> "v1.0.3".

Then, after the pull request is accepted and merged to the master, tag the master as v1.0.3 and update the latest version to luarocks server (I can help you in this step). So, then we will have this new feature published in release 1.0.3-0.

@tsyrjanen
Copy link
Collaborator

LGTM

@mkulikk
Copy link
Author

mkulikk commented Sep 18, 2017

Changed version number in rockspec and added brief description into README.md

Copy link
Contributor

@Trojan295 Trojan295 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments. I'll give my approval, if you refactor those nested if's and set the authenticated_consumer for Kong.

end

if res and res.user then
utils.injectUser(res.user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user field isn't, when the user uses this flow. So Kong doesn't know, that the requests is already authenticated. You would need to set minimum the authenticated_consumer.id field from the subject claim.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed -> now providing sub field as consumer id

if config.recovery_page_path then
ngx.log(ngx.DEBUG, "Entering recovery page: " .. config.recovery_page_path)
return ngx.redirect(config.recovery_page_path)
ngx.log(ngx.DEBUG, "In plugin CustomHandler:proceeding with two legged authentication, requested path: " .. ngx.var.request_uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log is kinda misleading. Sending a token doesn't mean the client used a two legged flow. It's out of scope for this plugin. It should only check, if the token it gets (no matter, if it's a access token, AAT, RPT) was created by the Authorization Server.
Also the CustomHandler is misleading, but IMO this is out of scope for this MR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed -> now it says that valid token can go through

@@ -4,6 +4,7 @@ return {
client_id = { type = "string", required = true },
client_secret = { type = "string", required = true },
discovery = { type = "string", required = true, default = "https://.well-known/openid-configuration" },
introspection_endpoint = { type = "string", required = false },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the Introspection Endpoint should be fetched from the OIDC Discovery Endpoint.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope -> in OAuth only AS you will not have discovery uri

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a plugin for OIDC, so you can assume, that there must be a Discovery Endpoint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introspection however is an optional extension to OAuth 2.0 and OIDC Discovery in its turn is OpenID Connect specific and predates the standardization of the introspection OAuth 2.0 extension, so OIDC Discovery hasn't standardized a key for the introspection endpoint

now there's WIP here https://tools.ietf.org/html/draft-ietf-oauth-discovery that standardizes Discovery for OAuth 2.0 and that includes the introspection endpoint... thats still TBD

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point exactly - Thank You !

@@ -29,27 +29,52 @@ function CustomHandler:access(config)

session.configure(config)

local res, err = require("resty.openidc").authenticate(oidcConfig)
if tryIntrospect(oidcConfig) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those nested if/else statements smell a bit. I would create a few functions, so it

[...] reads like well-written prose

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, reveal us those few functions you would write instead of nested ifs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created doAuthentication function to make code more clear

Copy link
Contributor

@Trojan295 Trojan295 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I would still seperate the standard RP flow and the proxied one, but I will try to do this in a seperate MR.

@Trojan295 Trojan295 mentioned this pull request Sep 19, 2017
@phirvone phirvone merged commit 994b0c2 into nokia:master Sep 25, 2017
thspinto pushed a commit to thspinto/kong-oidc that referenced this pull request Feb 16, 2021
PeeraJ pushed a commit to appman-agm/kong-oidc that referenced this pull request Jul 12, 2022
added scope validation unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants