[identity] Add support for session id in mobile flows#1103
Merged
Conversation
…est with UpdateAccessTokenClaimsOnRefresh
…est with UpdateAccessTokenClaimsOnRefresh
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
NikosDevPhp
force-pushed
the
feature/identity-support-mobile-sessionId
branch
from
July 20, 2026 14:57
c0fedc0 to
4f86945
Compare
…ithub.com/indice-co/Indice.AspNet into feature/identity-support-mobile-sessionId # Conflicts: # test/Indice.Features.Identity.Tests/CustomGrantsIntegrationTests.cs
…fresh with SessionId
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces explicit sid (session id) population for mobile-oriented token flows, aligning behavior across password/extension grants and adding integration coverage to ensure session id issuance/preservation (including refresh scenarios and server-side sessions interaction).
Changes:
- Populate
ValidatedRequest.SessionIdduring password and extension grant token processing sosidis present in issued tokens. - Add/extend integration tests validating
sidissuance, refresh preservation, and expected server-side session behavior for mobile clients. - Bump Identity/IdentityUI version prefixes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| test/Indice.Features.Identity.Tests/MobileSessionIdServerSideSessionsTests.cs | Adds a dedicated NET9+ integration test suite around mobile session id + server-side sessions behavior. |
| test/Indice.Features.Identity.Tests/CustomGrantsIntegrationTests.cs | Extends existing integration tests to assert sid exists across multiple token issuance flows and refresh. |
| src/Indice.Features.Identity.Core/ResponseHandling/ExtendedTokenResponseGenerator.cs | Sets ValidatedRequest.SessionId for password and extension grants to ensure sid is emitted. |
| src/Directory.Build.props | Increments Identity/IdentityUI version prefixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…eration, fix disposing in tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@cleftheris
Squash if merged.
sidclaim is stripped by default because JwtClaimTypes.SessionId is on IdentityServer4's hardcoded protocol-claim filter lists in Constants.Filters — both ProtocolClaimsFilter and ClaimsServiceFilterClaimTypes, the latter being described as the filter for claims returned from the profile service prior to creating tokens - not applicable here it strips before.This happens after GetProfileData. ExtendedTokenResponseGenerator adds the claim in ValidatedRequest.Subject -> ITokenService -> DefaultClaimsService.GetAccessTokenClaimsAsync / GetIdentityTokenClaimsAsync -> ExtendedProfileService
Checked against latest IS4 I have, for a previous - should be close to latest. - see below.
https://github.com/DuendeArchive/IdentityServer4/blob/295026919db5bec1b0c8f36fc89e8aeb4b5a0e3f/src/IdentityServer4/Services/DefaultClaimsService.cs
Instead of overriding something in the chain, we can use the intented way which should be
include sid (if present) in access tokens #3955 DuendeArchive/IdentityServer4#4202
There is a discrepancy between IS4 and Duende when UpdateAccessTokenClaimsOnRefresh is set to true on a client.
Refresh_Token_Preserves_SessionId_When_Client_Updates_Claims_On_Refresh intentionally skipped.
Probably here is the root cause:
IS4 does not populate the SessionId:
https://github.com/DuendeArchive/IdentityServer4/blob/5e40bd18fbf030d0158a15532eb8381c454b53da/src/IdentityServer4/src/Validation/Default/TokenRequestValidator.cs#L526
Duende populates the SessionId: https://github.com/DuendeSoftware/products/blob/e3479e955b0c5515d76391561f76d18b2074a2ea/identity-server/src/IdentityServer/Validation/Default/TokenRequestValidator.cs#L772
This PR fix made only on Duende(?)
DuendeArchive/Support#99
DuendeSoftware/products#944