-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bugfix/Authentication #215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
I just left a few comments and maybe add one more test to ensure no more information is returned about the user apart from username
and roles
.
Regarding this: "2. Checking the introspected information: is the user still active?
". How does the checking if the user is still active done? Is it implicitly done as part of the keycloak_openid.introspect()
or is it implemented in the code more explicitly?
Other than that, all good! :)
This is done in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving it.
Well done, nice job!
Use
keycloak_openid.introspect(token)
instead ofkeycloak_openid.userinfo(token)
.The previous code used the bearer token to authenticate to Keycloak. In other words, it authenticated with Keycloak in the name of the user. (http://openid.net/specs/openid-connect-core-1_0.html#UserInfo) This meant that the
client_id
andclient_secret
were ignored. This is not directly unsafe, but it removes a layer of defense.Instead, we want to authenticate as the AIoD API using the
client_id
andclient_secret
. We can do that usingintrospect
: https://datatracker.ietf.org/doc/html/rfc7662.Couple of other changes:
User
object is returned, with only the username and roles. This way, we're sure not to leak any other information to our own application, and by extension to endpoints such as /authentication-test (just as precaution). Moreover, it simplifies the rest of the code, making authorization-checks less error-prone.