Update sample to use OpenID Connect and Provider Configuration endpoint

Issue gh-53 gh-55
This commit is contained in:
Joe Grandja
2020-12-10 15:46:56 -05:00
parent f2bb523105
commit 668bb069f2
4 changed files with 25 additions and 6 deletions

View File

@@ -23,9 +23,11 @@ import org.springframework.security.crypto.key.CryptoKeySource;
import org.springframework.security.crypto.key.StaticKeyGeneratingCryptoKeySource;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
import org.springframework.security.oauth2.core.oidc.OidcScopes;
import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.config.ProviderSettings;
import java.util.UUID;
@@ -45,8 +47,11 @@ public class AuthorizationServerConfig {
.clientSecret("secret")
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
.redirectUri("http://localhost:8080/login/oauth2/code/messaging-client-oidc")
.redirectUri("http://localhost:8080/authorized")
.scope(OidcScopes.OPENID)
.scope("message.read")
.scope("message.write")
.clientSettings(clientSettings -> clientSettings.requireUserConsent(true))
@@ -59,4 +64,9 @@ public class AuthorizationServerConfig {
public CryptoKeySource keySource() {
return new StaticKeyGeneratingCryptoKeySource();
}
@Bean
public ProviderSettings providerSettings() {
return new ProviderSettings().issuer("http://auth-server:9000");
}
}