Change default authority for oauth2Login()

Previously, the default authority was ROLE_USER when using
oauth2Login() for both OAuth2 and OIDC providers.

* Default authority for OAuth2UserAuthority is now OAUTH2_USER
* Default authority for OidcUserAuthority is now OIDC_USER

Documentation has been updated to include this implementation detail.

Closes gh-7856
This commit is contained in:
Steve Riesenberg
2022-09-15 17:16:27 -05:00
parent 7527fd811c
commit 181ee7410b
9 changed files with 33 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,13 +48,13 @@ public class OidcUserAuthority extends OAuth2UserAuthority {
/**
* Constructs a {@code OidcUserAuthority} using the provided parameters and defaults
* {@link #getAuthority()} to {@code ROLE_USER}.
* {@link #getAuthority()} to {@code OIDC_USER}.
* @param idToken the {@link OidcIdToken ID Token} containing claims about the user
* @param userInfo the {@link OidcUserInfo UserInfo} containing claims about the user,
* may be {@code null}
*/
public OidcUserAuthority(OidcIdToken idToken, OidcUserInfo userInfo) {
this("ROLE_USER", idToken, userInfo);
this("OIDC_USER", idToken, userInfo);
}
/**

View File

@@ -43,11 +43,11 @@ public class OAuth2UserAuthority implements GrantedAuthority {
/**
* Constructs a {@code OAuth2UserAuthority} using the provided parameters and defaults
* {@link #getAuthority()} to {@code ROLE_USER}.
* {@link #getAuthority()} to {@code OAUTH2_USER}.
* @param attributes the attributes about the user
*/
public OAuth2UserAuthority(Map<String, Object> attributes) {
this("ROLE_USER", attributes);
this("OAUTH2_USER", attributes);
}
/**