How Can I Update my BFF Claims Without Re-Signing In #102
Replies: 2 comments 7 replies
-
I'm sorry, but I can't quite follow what the problem is. Do I understand correctly:
If this is correct, can you please explain how this problem relates to the id token and session? |
Beta Was this translation helpful? Give feedback.
-
If I get this right, the new claim is available to IdentityServer, but only after the IdentityServer session was created. Now you want the new claim to be visible to the BFF client? I would like to give a bit of background on how the IdentityServer session relates to the claims available on the user info endpoint of IdentityServer and to the token factory internally in IdentityServer. The main purpose of the IdentityServer session is to provide the claims required to show the IdentityServer UI. The user info endpoint and the token factories also need access to the claims of the user. They get those from the profile service. The profile service can interact with a database or external APIs to supply claims. Now, there's a twist to this - IdentityServer does not ship with a user store, there might not even be one. So if there is no store to load claims of the user from, how to implement the profile service? The
If this new claim is not needed for the IdentityServer UI, there is no need to do that1. My recommendation is to implement a custom For your existing native app, there is an additional setting needed. When an access token is refreshed, the default is to just copy the claims from the expired access token. To override that and cause the profile service to be invoked, set the For your BFF app, there might be another step required. If your BFF app signin happens after the extra claim is made available on the profile service it will just work. If the BFF app creates the BFF session before that claim is available, the BFF needs to refresh the session to get the extra claim. Please let me know if that is the case and I'll extend the answer. Footnotes
|
Beta Was this translation helpful? Give feedback.
-
BFF version
2.x
.NET version
8.x
Description
I have a mobile client and web client that work with my IdentityServer. The mobile client is a normal native app that uses the access token to access a backend API, but my web client uses the BFF framework to interact with the IdentityServer. I have a requirement to add a claim to the user's session after they have already logged in, so it would not be issued during sign-in, but later they can trigger an action that adds the claim. I believe I can accomplish this by using a custom extension grant on the IdentityServer that does a token exchange where they pass in their current access token, plus some additional values, and get back a new access token with the claim in it (as described here Token Exchange ). This should work fine for mobile, since any future calls to the API will use the new access token and thus will have the claim available in the API.
For my BFF host, however, I'm not sure how to get the new claims available to the BFF framework. It appears from the documentation that the BFF framework relies on the userinfo endpoint to retrieve claims rather than reading them from the access token or ID token. The problem is, since the claim will only exist in the new access token (and not on their ID server session, since it wasn't added during login), I don't know how to get the BFF host to "see" the new claim.
I also considered adding it to their IdentityServer session (I'm using server-side sessions on the IdentityServer as well), but I don't know how to add a claim to the IdentityServer session after login without having to force the customer to re-login again. From what I can tell, the ticket in the server-side session is static and doesn't change once the user is logged in.
Any suggestions for solving this?
Reproduction steps
n/a
Expected behavior
I would like to be able to tell the BFF server to refresh it's claims using the ID token instead of forcing it to re-call the userinfo endpoint.
Logs
Additional context
I'm using IdentityServer V7 and BFF V2. I am using server-side sessions on both the IdentityServer and the BFF Host.
Beta Was this translation helpful? Give feedback.
All reactions