-
Notifications
You must be signed in to change notification settings - Fork 60
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
userinfo_endpoint #438
Comments
Hi! have you tried to configure custom claims? ref: https://github.com/navikt/mock-oauth2-server#json_config |
This issue is stale because it has been open for 60 days with no activity. |
Sorry to reopen this, we are running into the same issue. |
@gpsmit If you do a GET to the /userinfo endpoint you will get the claims that are inside the token you use for auth (i.e. the bearer token in the authorization header), so you can use requestmapping to include the claims you want when you obtain that token. |
Maybe i understand the json config file usage incorrectly, but that returns a certain configured request when the request matches specific parameters in the call right?
We have a spring boot app that uses the oauth2 client to authenticate a user with oauth2 scopes of openid,profile,email the spring boot oauth2 flow automatically goes to the /userinfo endpoint after authentication to retrieve the user details, but no claims mapping from the json.config file is ever returned by the mock server. EDIT: I see that the token requests are transformed to a http request before the request mappings are evaluated, still im not sure how to mock /userinfo data, config as above does not seem to work. Are tokens presented to the /userinfo endpoint also transformed and evaluated in the same way as token requests? |
Any advice? |
The user_info has no params, so no params is checked. When a GET to |
https://openid.net/specs/openid-connect-core-1_0.html#UserInfo @gpsmit im not so familiar with spring and the ouath2 client, but can you intercept the Bearer token/request sent to the mock-oauth2-server? |
@ybelMekk sorry was on vacation for two weeks.
|
Perhaps the above config is not appropriate for user info calls, then I would love to know how one would go about configuring mock values for the user info endpoint. |
@gpsmit |
@gpsmit, after conducting some tests and observations, I'd like to explain the following: {
"interactiveLogin": true,
"httpServer": "NettyWrapper",
"tokenCallbacks": [
{
"issuerId": "issuer1",
"tokenExpiry": 120,
"requestMappings": [
{
"requestParam": "scope",
"match": "read",
"claims": {
"email": "[email protected]"
}
}
]
}
]
}
To demonstrate, consider the following curl command: curl -k -v -X POST -H 'Content-type: application/x-www-form-urlencoded' \
-d "client_id=mytestclient&scope=read&grant_type=client_credentials http://localhost:8080/issuer1/token Executing this command should generate a token containing the custom claim "email": "[email protected]". Following this, you can make a request to the info_endpoint using: curl -H "Authorization: Bearer ey.." http://localhost:8080/issuer1/userinfo The response should resemble the following JSON: {
"sub" : "testuser1",
"aud" : [ "read" ],
"nbf" : 1696922793000,
"azp" : "mytestclient",
"iss" : "http://localhost:8080/issuer1",
"exp" : 1696926393000,
"iat" : 1696922793000,
"email": "[email protected]"
"jti" : "645ef42b-771c-4fa9-83cc-07d9e0943ea1",
"tid" : "issuer1"
} I hope this has provided some clarity. |
Thanks for clarifying. Still some discussion: I guess my confusion arose from the exact whole string match: It would be nice to be able to partial match on the requestParams, as scope values are almost always multi value. So a working config for the issue I described above would be:
Anyway, thanks for working through this with me. |
This can be a nice little feature, I can look into it 👍🏾 |
thanks guys, amazing work. |
hi, is there a way to add fake data to userinfo_endpoint?
email, name etc.
The text was updated successfully, but these errors were encountered: