-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): added token exchange grant
Native SSO #2518
- Loading branch information
Showing
12 changed files
with
329 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
jans-auth-server/server/src/main/java/io/jans/as/server/model/common/TokenExchangeGrant.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.jans.as.server.model.common; | ||
|
||
import io.jans.as.common.model.common.User; | ||
import io.jans.as.common.model.registration.Client; | ||
import io.jans.as.model.common.GrantType; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
public class TokenExchangeGrant extends AuthorizationGrant { | ||
|
||
public TokenExchangeGrant() { | ||
} | ||
|
||
public void init(User user, Client client) { | ||
super.init(user, AuthorizationGrantType.TOKEN_EXCHANGE, client, null); | ||
} | ||
|
||
@Override | ||
public GrantType getGrantType() { | ||
return GrantType.TOKEN_EXCHANGE; | ||
} | ||
} |
This file contains 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
46 changes: 46 additions & 0 deletions
46
...-auth-server/server/src/main/java/io/jans/as/server/token/ws/rs/TokenInternalService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.jans.as.server.token.ws.rs; | ||
|
||
import io.jans.as.common.model.session.SessionId; | ||
import io.jans.as.model.configuration.AppConfiguration; | ||
import io.jans.as.server.model.token.HandleTokenFactory; | ||
import io.jans.as.server.service.SessionIdService; | ||
import jakarta.ejb.Stateless; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import org.apache.commons.lang3.BooleanUtils; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
@Stateless | ||
@Named | ||
public class TokenInternalService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private AppConfiguration appConfiguration; | ||
|
||
@Inject | ||
private SessionIdService sessionIdService; | ||
|
||
public String rotateDeviceSecret(SessionId sessionId, String actorToken) { | ||
if (BooleanUtils.isFalse(appConfiguration.getRotateDeviceSecret())) { | ||
return null; | ||
} | ||
|
||
String newDeviceSecret = HandleTokenFactory.generateDeviceSecret(); | ||
|
||
final List<String> deviceSecrets = sessionId.getDeviceSecrets(); | ||
deviceSecrets.remove(actorToken); | ||
deviceSecrets.add(newDeviceSecret); | ||
|
||
sessionIdService.updateSessionId(sessionId, false); | ||
|
||
return newDeviceSecret; | ||
} | ||
} |
This file contains 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
Oops, something went wrong.