From c111099640e75a2527f8ffdcf074a8af57907e84 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Mon, 2 Mar 2020 14:13:59 -0500 Subject: [PATCH] Polish client-registration xsd attributes Issue gh-4557 --- ...ientRegistrationsBeanDefinitionParser.java | 32 +++++++++---------- .../security/config/spring-security-5.3.rnc | 8 ++--- .../security/config/spring-security-5.3.xsd | 8 ++--- ...onParserTests-SingleClientRegistration.xml | 8 ++--- .../client/google-github-registration.xml | 14 ++++---- .../oauth2/client/google-registration.xml | 8 ++--- .../_includes/servlet/appendix/namespace.adoc | 16 +++++----- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java index 4dfbae5819..62b28ddb5f 100644 --- a/config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java @@ -57,10 +57,10 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini private static final String ATT_PROVIDER_ID = "provider-id"; private static final String ATT_AUTHORIZATION_URI = "authorization-uri"; private static final String ATT_TOKEN_URI = "token-uri"; - private static final String ATT_USERINFO_URI = "userinfo-uri"; - private static final String ATT_USERINFO_AUTHENTICATION_METHOD = "userinfo-authentication-method"; - private static final String ATT_USERNAME_ATTRIBUTE_NAME = "username-attribute-name"; - private static final String ATT_JWKSET_URI = "jwkset-uri"; + private static final String ATT_USER_INFO_URI = "user-info-uri"; + private static final String ATT_USER_INFO_AUTHENTICATION_METHOD = "user-info-authentication-method"; + private static final String ATT_USER_INFO_USER_NAME_ATTRIBUTE = "user-info-user-name-attribute"; + private static final String ATT_JWK_SET_URI = "jwk-set-uri"; private static final String ATT_ISSUER_URI = "issuer-uri"; @Override @@ -138,14 +138,14 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini .ifPresent(value -> provider.put(ATT_AUTHORIZATION_URI, value)); getOptionalIfNotEmpty(providerElt.getAttribute(ATT_TOKEN_URI)) .ifPresent(value -> provider.put(ATT_TOKEN_URI, value)); - getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USERINFO_URI)) - .ifPresent(value -> provider.put(ATT_USERINFO_URI, value)); - getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USERINFO_AUTHENTICATION_METHOD)) - .ifPresent(value -> provider.put(ATT_USERINFO_AUTHENTICATION_METHOD, value)); - getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USERNAME_ATTRIBUTE_NAME)) - .ifPresent(value -> provider.put(ATT_USERNAME_ATTRIBUTE_NAME, value)); - getOptionalIfNotEmpty(providerElt.getAttribute(ATT_JWKSET_URI)) - .ifPresent(value -> provider.put(ATT_JWKSET_URI, value)); + getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USER_INFO_URI)) + .ifPresent(value -> provider.put(ATT_USER_INFO_URI, value)); + getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USER_INFO_AUTHENTICATION_METHOD)) + .ifPresent(value -> provider.put(ATT_USER_INFO_AUTHENTICATION_METHOD, value)); + getOptionalIfNotEmpty(providerElt.getAttribute(ATT_USER_INFO_USER_NAME_ATTRIBUTE)) + .ifPresent(value -> provider.put(ATT_USER_INFO_USER_NAME_ATTRIBUTE, value)); + getOptionalIfNotEmpty(providerElt.getAttribute(ATT_JWK_SET_URI)) + .ifPresent(value -> provider.put(ATT_JWK_SET_URI, value)); getOptionalIfNotEmpty(providerElt.getAttribute(ATT_ISSUER_URI)) .ifPresent(value -> provider.put(ATT_ISSUER_URI, value)); providers.put(providerId, provider); @@ -190,14 +190,14 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini .ifPresent(builder::authorizationUri); getOptionalIfNotEmpty(provider.get(ATT_TOKEN_URI)) .ifPresent(builder::tokenUri); - getOptionalIfNotEmpty(provider.get(ATT_USERINFO_URI)) + getOptionalIfNotEmpty(provider.get(ATT_USER_INFO_URI)) .ifPresent(builder::userInfoUri); - getOptionalIfNotEmpty(provider.get(ATT_USERINFO_AUTHENTICATION_METHOD)) + getOptionalIfNotEmpty(provider.get(ATT_USER_INFO_AUTHENTICATION_METHOD)) .map(AuthenticationMethod::new) .ifPresent(builder::userInfoAuthenticationMethod); - getOptionalIfNotEmpty(provider.get(ATT_JWKSET_URI)) + getOptionalIfNotEmpty(provider.get(ATT_JWK_SET_URI)) .ifPresent(builder::jwkSetUri); - getOptionalIfNotEmpty(provider.get(ATT_USERNAME_ATTRIBUTE_NAME)) + getOptionalIfNotEmpty(provider.get(ATT_USER_INFO_USER_NAME_ATTRIBUTE)) .ifPresent(builder::userNameAttributeName); return builder; } diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-5.3.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-5.3.rnc index 79dfe1b74e..337d5008af 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-5.3.rnc +++ b/config/src/main/resources/org/springframework/security/config/spring-security-5.3.rnc @@ -558,16 +558,16 @@ provider.attlist &= attribute token-uri {xsd:token}? provider.attlist &= ## The UserInfo Endpoint URI used to access the claims/attributes of the authenticated end-user. - attribute userinfo-uri {xsd:token}? + attribute user-info-uri {xsd:token}? provider.attlist &= ## The authentication method used when sending the access token to the UserInfo Endpoint. The supported values are header, form and query. - attribute userinfo-authentication-method {"header" | "form" | "query"}? + attribute user-info-authentication-method {"header" | "form" | "query"}? provider.attlist &= ## The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user. - attribute username-attribute-name {xsd:token}? + attribute user-info-user-name-attribute {xsd:token}? provider.attlist &= ## The URI used to retrieve the JSON Web Key (JWK) Set from the Authorization Server, which contains the cryptographic key(s) used to verify the JSON Web Signature (JWS) of the ID Token and optionally the UserInfo Response. - attribute jwkset-uri {xsd:token}? + attribute jwk-set-uri {xsd:token}? provider.attlist &= ## The URI used to discover the configuration information for an OAuth 2.0 or OpenID Connect 1.0 Provider. attribute issuer-uri {xsd:token}? diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-5.3.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-5.3.xsd index 88c5f2cb8b..e7849864ba 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-5.3.xsd +++ b/config/src/main/resources/org/springframework/security/config/spring-security-5.3.xsd @@ -1737,14 +1737,14 @@ - + The UserInfo Endpoint URI used to access the claims/attributes of the authenticated end-user. - + The authentication method used when sending the access token to the UserInfo Endpoint. The supported values are header, form and query. @@ -1758,14 +1758,14 @@ - + The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user. - + The URI used to retrieve the JSON Web Key (JWK) Set from the Authorization Server, which contains the cryptographic key(s) used to verify the JSON Web Signature (JWS) of the ID diff --git a/config/src/test/resources/org/springframework/security/config/http/OAuth2LoginBeanDefinitionParserTests-SingleClientRegistration.xml b/config/src/test/resources/org/springframework/security/config/http/OAuth2LoginBeanDefinitionParserTests-SingleClientRegistration.xml index 66660c5a4a..40b4240424 100644 --- a/config/src/test/resources/org/springframework/security/config/http/OAuth2LoginBeanDefinitionParserTests-SingleClientRegistration.xml +++ b/config/src/test/resources/org/springframework/security/config/http/OAuth2LoginBeanDefinitionParserTests-SingleClientRegistration.xml @@ -43,10 +43,10 @@ + user-info-uri="https://www.googleapis.com/oauth2/v3/userinfo" + user-info-authentication-method="header" + user-info-user-name-attribute="sub" + jwk-set-uri="https://www.googleapis.com/oauth2/v3/certs"/> diff --git a/config/src/test/resources/org/springframework/security/config/oauth2/client/google-github-registration.xml b/config/src/test/resources/org/springframework/security/config/oauth2/client/google-github-registration.xml index 004657dfe6..b875b2cb58 100644 --- a/config/src/test/resources/org/springframework/security/config/oauth2/client/google-github-registration.xml +++ b/config/src/test/resources/org/springframework/security/config/oauth2/client/google-github-registration.xml @@ -45,15 +45,15 @@ + user-info-uri="https://www.googleapis.com/oauth2/v3/userinfo" + user-info-authentication-method="header" + user-info-user-name-attribute="sub" + jwk-set-uri="https://www.googleapis.com/oauth2/v3/certs"/> + user-info-uri="https://api.github.com/user" + user-info-authentication-method="header" + user-info-user-name-attribute="id"/> diff --git a/config/src/test/resources/org/springframework/security/config/oauth2/client/google-registration.xml b/config/src/test/resources/org/springframework/security/config/oauth2/client/google-registration.xml index 46b88b41f0..df244c5924 100644 --- a/config/src/test/resources/org/springframework/security/config/oauth2/client/google-registration.xml +++ b/config/src/test/resources/org/springframework/security/config/oauth2/client/google-registration.xml @@ -36,9 +36,9 @@ + user-info-uri="https://www.googleapis.com/oauth2/v3/userinfo" + user-info-authentication-method="header" + user-info-user-name-attribute="sub" + jwk-set-uri="https://www.googleapis.com/oauth2/v3/certs"/> diff --git a/docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc b/docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc index a4b7b65c78..789fd4a57c 100644 --- a/docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc +++ b/docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc @@ -1136,24 +1136,24 @@ The Authorization Endpoint URI for the Authorization Server. The Token Endpoint URI for the Authorization Server. -[[nsa-provider-userinfo-uri]] -* **userinfo-uri** +[[nsa-provider-user-info-uri]] +* **user-info-uri** The UserInfo Endpoint URI used to access the claims/attributes of the authenticated end-user. -[[nsa-provider-userinfo-authentication-method]] -* **userinfo-authentication-method** +[[nsa-provider-user-info-authentication-method]] +* **user-info-authentication-method** The authentication method used when sending the access token to the UserInfo Endpoint. The supported values are *header*, *form* and *query*. -[[nsa-provider-username-attribute-name]] -* **username-attribute-name** +[[nsa-provider-user-info-user-name-attribute]] +* **user-info-user-name-attribute** The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user. -[[nsa-provider-jwkset-uri]] -* **jwkset-uri** +[[nsa-provider-jwk-set-uri]] +* **jwk-set-uri** The URI used to retrieve the https://tools.ietf.org/html/rfc7517[JSON Web Key (JWK)] Set from the Authorization Server, which contains the cryptographic key(s) used to verify the https://tools.ietf.org/html/rfc7515[JSON Web Signature (JWS)] of the ID Token and optionally the UserInfo Response.