Skip to content

Commit

Permalink
Put unknown email domains in user tag
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Apr 10, 2024
1 parent e060dfe commit 1650713
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/jasper/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class SecurityConfig implements Serializable {
private String tokenEndpoint = "";
private String scimEndpoint = "";
private String usernameClaim = "sub";
private boolean emailDomainInUsername = false;
private String rootEmailDomain = "";
private String verifiedEmailClaim = "verified_email";
private String authoritiesClaim = "auth";
private String readAccessClaim = "readAccess";
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/jasper/security/jwt/TokenProviderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ String getUsername(Claims claims, String origin) {
}
logger.debug("Principal: {}", principal);
if (principal.contains("@")) {
// TODO: option for: map email host to user tag path
var emailDomain = principal.substring(principal.indexOf("@"));
principal = principal.substring(0, principal.indexOf("@"));
var security = configs.security(origin);
if (security.isEmailDomainInUsername() && !emailDomain.equals(security.getRootEmailDomain())) {
principal = emailDomain + "/" + principal;
}
}
var authorities = getPartialAuthorities(claims, origin);
if (isBlank(principal) ||
Expand Down

0 comments on commit 1650713

Please sign in to comment.