Skip to content
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

feat(jans-auth-server): added convenient idTokenLifetime client property #2656 #2668

Merged
merged 1 commit into from
Oct 19, 2022
Merged
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
Expand Up @@ -101,6 +101,17 @@ public class ClientAttributes implements Serializable {
@JsonProperty("jansDefaultPromptLogin")
private Boolean defaultPromptLogin = false;

@JsonProperty("idTokenLifetime")
private Integer idTokenLifetime;

public Integer getIdTokenLifetime() {
return idTokenLifetime;
}

public void setIdTokenLifetime(Integer idTokenLifetime) {
this.idTokenLifetime = idTokenLifetime;
}

public List<String> getRopcScripts() {
if (ropcScripts == null) ropcScripts = new ArrayList<>();
return ropcScripts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ private void fillClaims(JsonWebResponse jwr,
AuthorizationCode authorizationCode, AccessToken accessToken, RefreshToken refreshToken,
ExecutionContext executionContext) throws Exception {

final Client client = authorizationGrant.getClient();
jwr.getClaims().setIssuer(appConfiguration.getIssuer());
Audience.setAudience(jwr.getClaims(), authorizationGrant.getClient());
Audience.setAudience(jwr.getClaims(), client);

int lifeTime = appConfiguration.getIdTokenLifetime();
if (client.getAttributes().getIdTokenLifetime() != null && client.getAttributes().getIdTokenLifetime() > 0) {
lifeTime = client.getAttributes().getIdTokenLifetime();
log.trace("Override id token lifetime with value from client: {}", client.getClientId());
}
int lifetimeFromScript = externalUpdateTokenService.getIdTokenLifetimeInSeconds(ExternalUpdateTokenContext.of(executionContext));
if (lifetimeFromScript > 0) {
lifeTime = lifetimeFromScript;
Expand Down Expand Up @@ -191,7 +196,7 @@ private void fillClaims(JsonWebResponse jwr,

User user = authorizationGrant.getUser();
List<Scope> dynamicScopes = new ArrayList<>();
if (executionContext.isIncludeIdTokenClaims() && authorizationGrant.getClient().isIncludeClaimsInIdToken()) {
if (executionContext.isIncludeIdTokenClaims() && client.isIncludeClaimsInIdToken()) {
for (String scopeName : executionContext.getScopes()) {
Scope scope = scopeService.getScopeById(scopeName);
if (scope == null) {
Expand Down