21 Eylül 2021 Salı

SpringSecurity OAuth2 Client ClientRegistration Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.security.oauth2.client.registration.ClientRegistration;
ClientRegistration Nedir?
Açıklaması şöyle
A client registration holds information, such as client id, client secret, authorization grant type, redirect URI, scope(s), authorization URI, token URI, and other details.
Örnek
Şöyle yaparız
private ClientRegistration createClientRegistration() {
  return ClientRegistration.withRegistrationId("onelogin")
      .clientId(oneLoginConfigs.getClientId())
      .clientSecret(oneLoginConfigs.getClientSecret())
      .clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
      .authorizationUri("https://company.onelogin.com/oidc/2/auth")
      .tokenUri("https://company.onelogin.com/oidc/2/token")
    
  .authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
      .redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
      .scope("openid", "profile", "email”)
      .userInfoUri("https://company.onelogin.com/oidc/2/me")
      .userNameAttributeName(IdTokenClaimNames.SUB)
      .jwkSetUri("https://company.onelogin.com/oidc/2/certs")
      .clientName("Zoo")
      .build();
}

Hiç yorum yok:

Yorum Gönder