Skip to content

Commit 2d3d578

Browse files
authored
Disable Single Logout by default (#126)
1 parent f6ed9bf commit 2d3d578

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/main/java/com/microsoft/jenkins/azuread/AzureSecurityRealm.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public class AzureSecurityRealm extends SecurityRealm {
109109
private Secret tenant;
110110
private int cacheDuration;
111111
private boolean fromRequest = false;
112+
private boolean singleLogout;
112113
private String azureEnvironmentName = "Azure";
113114

114115
private final Supplier<GraphServiceClient<Request>> cachedAzureClient = Suppliers.memoize(() -> {
@@ -164,6 +165,15 @@ private static OkHttpClient.Builder addProxyToHttpClientIfRequired(OkHttpClient.
164165
}
165166

166167

168+
public boolean isSingleLogout() {
169+
return singleLogout;
170+
}
171+
172+
@DataBoundSetter
173+
public void setSingleLogout(boolean singleLogout) {
174+
this.singleLogout = singleLogout;
175+
}
176+
167177
private final Supplier<JwtConsumer> jwtConsumer = Suppliers.memoize(() ->
168178
Utils.JwtUtil.jwt(getClientId(), getTenant()));
169179

@@ -383,7 +393,11 @@ protected String getPostLogOutUrl2(StaplerRequest req, Authentication auth) {
383393
AzureCachePool.invalidateBelongingGroupsByOid(oid);
384394
}
385395
// Ensure single sign-out
386-
return getOAuthService().getLogoutUrl();
396+
397+
if (singleLogout) {
398+
return getOAuthService().getLogoutUrl();
399+
}
400+
return req.getContextPath() + "/";
387401
}
388402

389403
@Override

src/main/resources/com/microsoft/jenkins/azuread/AzureSecurityRealm/config.jelly

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<f:checkbox />
3131
</f:entry>
3232

33+
<f:entry title="${%Enable Single Logout}" field="singleLogout">
34+
<f:checkbox />
35+
</f:entry>
36+
3337
<f:entry title="Test user principal name or object id">
3438
<f:textbox name="testObject" />
3539
</f:entry>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>
2+
Single Logout will sign the user out of all Azure Active Directory sessions and not just Jenkins.
3+
</p>
4+
<p>
5+
This is a security hardening that some organisations may want to enable, but is a poor user experience.
6+
</p>
7+
<p>
8+
Users using applications like teams or outlook in the browser will be logged out and won't continue receiving emails
9+
and messages.
10+
</p>

0 commit comments

Comments
 (0)