Skip to content

Commit 1cc7a73

Browse files
committed
Revert "Add OAuth2AuthenticatedPrincipal.getNameAttributeKey"
This reverts commit 464b078.
1 parent 88b0d4d commit 1cc7a73

File tree

4 files changed

+4
-26
lines changed

4 files changed

+4
-26
lines changed

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/DefaultOAuth2AuthenticatedPrincipal.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public DefaultOAuth2AuthenticatedPrincipal(String name, Map<String, Object> attr
6464
this.attributes = Collections.unmodifiableMap(attributes);
6565
this.authorities = (authorities != null) ? Collections.unmodifiableCollection(authorities)
6666
: AuthorityUtils.NO_AUTHORITIES;
67-
this.name = (name != null) ? name : (String) this.attributes.get(this.getNameAttributeKey());
67+
this.name = (name != null) ? name : (String) this.attributes.get("sub");
6868
}
6969

7070
/**
@@ -81,11 +81,6 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
8181
return this.authorities;
8282
}
8383

84-
@Override
85-
public String getNameAttributeKey() {
86-
return "sub";
87-
}
88-
8984
@Override
9085
public String getName() {
9186
return this.name;

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthenticatedPrincipal.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,11 +57,4 @@ default <A> A getAttribute(String name) {
5757
*/
5858
Collection<? extends GrantedAuthority> getAuthorities();
5959

60-
/**
61-
* Get the key used to access the user's &quot;name&quot; from {@link #getAttributes()}
62-
* @return the key used to access the user's &quot;name&quot;
63-
* @since 6.4
64-
*/
65-
String getNameAttributeKey();
66-
6760
}

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/user/DefaultOAuth2User.java

-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ public Map<String, Object> getAttributes() {
9494
return this.attributes;
9595
}
9696

97-
@Override
98-
public String getNameAttributeKey() {
99-
return this.nameAttributeKey;
100-
}
101-
10297
private Set<GrantedAuthority> sortAuthorities(Collection<? extends GrantedAuthority> authorities) {
10398
SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet<>(
10499
Comparator.comparing(GrantedAuthority::getAuthority));

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/OAuth2IntrospectionAuthenticatedPrincipal.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,11 +80,6 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
8080
return this.delegate.getAuthorities();
8181
}
8282

83-
@Override
84-
public String getNameAttributeKey() {
85-
return this.delegate.getNameAttributeKey();
86-
}
87-
8883
@Override
8984
public String getName() {
9085
return this.delegate.getName();

0 commit comments

Comments
 (0)