Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2025-2026, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -4988,6 +4988,7 @@ private static void addUserAttributesToCache(OAuthMessage oAuthMessage, String d
if (oAuthMessage.getProperty(IMPERSONATING_ACTOR) != null) {
cacheEntry.setImpersonator(oAuthMessage.getProperty(IMPERSONATING_ACTOR).toString());
}
cacheEntry.setSessionContextIdentifier(sessionDataCacheEntry.getSessionContextIdentifier());

DeviceAuthorizationGrantCache.getInstance().addToCache(cacheKey, cacheEntry);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com)
* Copyright (c) 2023-2026, WSO2 LLC. (https://www.wso2.com)
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -33,6 +33,7 @@ public class DeviceAuthorizationGrantCacheEntry extends CacheEntry {
private Map<ClaimMapping, String> userAttributes;
private Map<ClaimMapping, String> mappedRemoteClaims;
private String impersonator;
private String sessionContextIdentifier;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this could lead to session deserialization issues. Could you take a look? @SujanSanjula96 may have more context.


public DeviceAuthorizationGrantCacheEntry(Map<ClaimMapping, String> userAttributes) {

Expand Down Expand Up @@ -79,4 +80,14 @@ public void setImpersonator(String impersonator) {

this.impersonator = impersonator;
}

public String getSessionContextIdentifier() {

return sessionContextIdentifier;
}

public void setSessionContextIdentifier(String sessionContextIdentifier) {

this.sessionContextIdentifier = sessionContextIdentifier;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2025, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2017-2026, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -128,6 +128,7 @@
import static org.wso2.carbon.identity.oauth2.Oauth2ScopeConstants.INTERNAL_SCOPE_PREFIX;
import static org.wso2.carbon.identity.oauth2.Oauth2ScopeConstants.SYSTEM_SCOPE;
import static org.wso2.carbon.identity.oauth2.device.constants.Constants.DEVICE_FLOW_GRANT_TYPE;
import static org.wso2.carbon.identity.oauth2.token.handlers.grant.RefreshGrantHandler.SESSION_IDENTIFIER;
import static org.wso2.carbon.identity.oauth2.util.OAuth2Util.EXTENDED_REFRESH_TOKEN_DEFAULT_TIME;
import static org.wso2.carbon.identity.oauth2.util.OAuth2Util.INTERNAL_LOGIN_SCOPE;
import static org.wso2.carbon.identity.oauth2.util.OAuth2Util.validateRequestTenantDomainWithOrgHierarchy;
Expand Down Expand Up @@ -225,6 +226,11 @@ public OAuth2AccessTokenRespDTO issue(OAuth2AccessTokenReqDTO tokenReqDTO)
AuthorizationGrantCacheEntry authorizationGrantCacheEntry =
getAuthzGrantCacheEntryFromDeviceCode(tokenReqDTO);
persistImpersonationInfoToTokenReqCtx(authorizationGrantCacheEntry, tokReqMsgCtx);
if (authorizationGrantCacheEntry != null
&& authorizationGrantCacheEntry.getSessionContextIdentifier() != null) {
tokReqMsgCtx.addProperty(SESSION_IDENTIFIER,
authorizationGrantCacheEntry.getSessionContextIdentifier());
}
}

triggerPreListeners(tokenReqDTO, tokReqMsgCtx, isRefreshRequest);
Expand Down Expand Up @@ -829,6 +835,8 @@ private Optional<AuthorizationGrantCacheEntry> getAuthzGrantCacheEntryFromDevice
authorizationGrantCacheEntry.setMappedRemoteClaims(cacheEntry
.getMappedRemoteClaims());
}
authorizationGrantCacheEntry.setSessionContextIdentifier(
cacheEntry.getSessionContextIdentifier());
persistImpersonationInfoToAuthzGrantCacheEntry(cacheEntry, authorizationGrantCacheEntry);
return Optional.of(authorizationGrantCacheEntry);
}
Expand Down
Loading