mirror of
https://github.com/traccar/traccar.git
synced 2025-01-07 03:07:01 +08:00
Refactor to use standard config default values
This commit is contained in:
parent
f2573b4485
commit
2e92a7cda8
@ -704,7 +704,8 @@ public final class Keys {
|
||||
*/
|
||||
public static final ConfigKey<String> OPENID_GROUPS_CLAIM_NAME = new StringConfigKey(
|
||||
"openid.groupsClaimName",
|
||||
List.of(KeyType.CONFIG));
|
||||
List.of(KeyType.CONFIG),
|
||||
"groups");
|
||||
|
||||
/**
|
||||
* OpenID Connect group to restrict access to.
|
||||
|
@ -33,7 +33,6 @@ import java.security.GeneralSecurityException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@ -122,7 +121,7 @@ public class OpenIdProvider {
|
||||
Scope scope = new Scope("openid", "profile", "email");
|
||||
|
||||
if (adminGroup != null) {
|
||||
scope.add(Objects.requireNonNullElse(groupsClaimName, "groups"));
|
||||
scope.add(groupsClaimName);
|
||||
}
|
||||
|
||||
AuthenticationRequest.Builder request = new AuthenticationRequest.Builder(
|
||||
@ -187,9 +186,7 @@ public class OpenIdProvider {
|
||||
|
||||
UserInfo userInfo = getUserInfo(bearerToken);
|
||||
|
||||
List<String> userGroups = groupsClaimName != null
|
||||
? userInfo.getStringListClaim(groupsClaimName)
|
||||
: userInfo.getStringListClaim("groups");
|
||||
List<String> userGroups = userInfo.getStringListClaim(groupsClaimName);
|
||||
boolean administrator = adminGroup != null && userGroups.contains(adminGroup);
|
||||
|
||||
if (!(administrator || allowGroup == null || userGroups.contains(allowGroup))) {
|
||||
|
Loading…
Reference in New Issue
Block a user