aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2023-04-03 14:39:55 -0700
committerGitHub <noreply@github.com>2023-04-03 14:39:55 -0700
commit61ea657e806c8412f23376ecc4f1e31025fc9bfc (patch)
tree1a0626c1db0cf02389f6b55bcd9767f232504130 /src/main/java/org/traccar/database
parent2d92fa2473b2317f01b904a8f1afd83e7884d7c8 (diff)
parentcf992ec194ef8fbcd86ad170bdc68c6075712591 (diff)
downloadtrackermap-server-61ea657e806c8412f23376ecc4f1e31025fc9bfc.tar.gz
trackermap-server-61ea657e806c8412f23376ecc4f1e31025fc9bfc.tar.bz2
trackermap-server-61ea657e806c8412f23376ecc4f1e31025fc9bfc.zip
Merge pull request #5060 from dan-r/oidc-tweaks
Minor tweaks to OpenID Connect integration
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/OpenIdProvider.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/database/OpenIdProvider.java b/src/main/java/org/traccar/database/OpenIdProvider.java
index f5c7eef15..537319b31 100644
--- a/src/main/java/org/traccar/database/OpenIdProvider.java
+++ b/src/main/java/org/traccar/database/OpenIdProvider.java
@@ -94,9 +94,15 @@ public class OpenIdProvider {
}
public URI createAuthUri() {
+ Scope scope = new Scope("openid", "profile", "email");
+
+ if (adminGroup != null) {
+ scope.add("groups");
+ }
+
AuthenticationRequest.Builder request = new AuthenticationRequest.Builder(
new ResponseType("code"),
- new Scope("openid", "profile", "email", "groups"),
+ scope,
clientId,
callbackUrl);
@@ -156,9 +162,9 @@ public class OpenIdProvider {
UserInfo userInfo = getUserInfo(bearerToken);
- User user = loginService.login(
- userInfo.getEmailAddress(), userInfo.getName(),
- userInfo.getStringListClaim("groups").contains(adminGroup));
+ Boolean administrator = adminGroup != null && userInfo.getStringListClaim("groups").contains(adminGroup);
+
+ User user = loginService.login(userInfo.getEmailAddress(), userInfo.getName(), administrator);
request.getSession().setAttribute(SessionResource.USER_ID_KEY, user.getId());
LogAction.login(user.getId(), ServletHelper.retrieveRemoteAddress(request));