| init | ํ๋ก์ ํธ ์์ฑ |
|---|---|
| feat | ์๋ก์ด ๊ธฐ๋ฅ์ ๋ํ ์ปค๋ฐ |
| build | ๋น๋ ๊ด๋ จ ํ์ผ ์์ / ๋ชจ๋ ์ค์น ๋๋ ์ญ์ ์ ๋ํ ์ปค๋ฐ |
| chore | ๊ทธ ์ธ ์์ํ ์์ ์ ๋ํ ์ปค๋ฐ |
| docs | ๋ฌธ์ ์์ ์ ๋ํ ์ปค๋ฐ |
| style | ์ฝ๋ ์คํ์ผ ํน์ ํฌ๋งท ๋ฑ์ ๊ดํ ์ปค๋ฐ |
| refactor | ์ฝ๋ ๋ฆฌํฉํ ๋ง์ ๋ํ ์ปค๋ฐ |
| test | ํ ์คํธ ์ฝ๋ ์์ ์ ๋ํ ์ปค๋ฐ |
| perf | ์ฑ๋ฅ ๊ฐ์ ์ ๋ํ ์ปค๋ฐ |
- OAuth = Open + Authorization ๊ธฐ๋ณธ ์๋ฆฌ๋ ์ ์ ๊ฐ ์น์ธํ์ ๋ค๋ฅธ ์๋ฒ์ ์ ์ ์ ์ ๋ณด๋ฅผ ์ค ์ ์๋ค๋ ๊ฒ์ ์๋ฏธํจ -> ์ด๋ฌํ ์ญํ ์ ํ๋ ๊ฒ์ด ์ธ๊ฐ ์๋ฒ๋ผ๊ณ ํจ.
- OAuth2.0 ๋ฉ์ปค๋์ฆ์ ๋ค์ 4๊ฐ์ง ์ข ๋ฅ์ ์ญํ ์ ๋ด๋นํ๋ ๊ถํ ๋ถ์ฌ ์ฒด๊ณ์ด๋ค.
- Resource Owner
- ๋ณดํธ๋ ์์์ ๋ํ ์ ๊ทผ ๊ถํ์ ๋ถ์ฌํ ์ ์๋ ์ฃผ์ฒด
- ์ฌ์ฉ์๋ฅผ ๋์ ํด์ ์๋ํ๋ ค๋ ๋ชจ๋ ํด๋ผ์ด์ธํธ๋ ์ฌ์ฉ์์ ํ๊ฐ๋ถํฐ ๋ฐ์์ผ ๋๋ค.
- Resource Server
- ํ์ฌ ์ดํ๋ฆฌ์ผ์ด์ ์์ ์ ๊ทผํ๋ ์ฌ์ฉ์์ ์์์ด ํฌํจ๋ ์๋ฒ๋ฅผ ์๋ฏธ
- ์ก์ธ์ค ํ ํฐ์ ์๋ฝ ๋ฐ ๊ฒ์ฆํ ์ ์์ด์ผ ํ๋ฉฐ ๊ถํ ์ฒด๊ณ์ ๋ฐ๋ผ ์์ฒญ ์น์ธํ ์ ์์ด์ผ ํ๋ค.
- Authorization Server
- ํด๋ผ์ด์ธํธ๊ฐ ์ฌ์ฉ์ ๊ณ์ ์ ๋ํ ๋์ ๋ฐ ์ ๊ทผ์ ์์ฒญํ ๋ ์ํธ์์ฉํ๋ ์๋ฒ๋ก ํด๋ผ์ด์ธํธ์ ๊ถํ ๋ถ์ฌ ์์ฒญ์ ์น์ธํ๊ฑฐ๋ ๊ฑฐ๋ถํ๋ ์๋ฒ
- ์ฌ์ฉ์๊ฐ ํด๋ผ์ด์ธํธ์๊ฒ ๊ถํ ๋ถ์ฌ ์์ฒญ์ ์น์ธํ ํ accessToken์ ํด๋ผ์๊ฒ ๋ถ์ฌํ๋ ์ญํ
- Client
- ์ฌ์ฉ์๋ฅผ ๋์ ํด์ ๊ถํ์ ๋ฐ์ ์ฌ์ฉ์์ ๋ฆฌ์์ค์ ์ ๊ทผํ๋ ค๋ ์ ํ๋ฆฌ์ผ์ด์
- ์ฌ์ฉ์๋ฅผ ๊ถํ ๋ถ์ฌ ์๋ฒ๋ก ์๋ดํ๊ฑฐ๋ ์ฌ์ฉ์์ ์ํธ์์ฉ ์์ด ๊ถํ ๋ถ์ฌ ์๋ฒ๋ก๋ถํฐ ์ง์ ๊ถํ์ ์ป์ ์ ์๋ค.
์ฐ๋ฆฌ๋ ๋ณดํต Client๋ง ์ฌ์ฉํด์ ๋ค๋ฅธ ์ธ๊ฐ ์๋ฒ์ธ ๊ตฌ๊ธ, ๋ค์ด๋ฒ, ์นด์นด์ค์ ์ธ๊ฐ ์์ฒญ์ ํ๊ฒ ๋๊ณ ์ดํ ํ ํฐ์ ๊ฐ์ง๊ณ ์ธ์ฆ์ ์ฒ๋ฆฌํ๊ฒ ๋๋ค.
OAuth2.0์ ์ธ๊ฐ์ ์ธ์ฆ ์ฒ๋ฆฌ๋ฅผ ๋ด๋ถ์ ์ผ๋ก ๊ฐ์ด ์ฒ๋ฆฌํ๊ธฐ ๋๋ฌธ์ ์ธ์ฆํ๋ ์์ํฌ๋ผ๊ณ ์๊ธฐ ์ฌ์ด๋ฐ OAuth2.0์ ์ธ๊ฐ ํ๋ ์์ํฌ์ด๋ค.
- Authorization Code Grant Type : ๊ถํ ์ฝ๋ ๋ถ์ฌ ํ์ , ์๋ฒ ์ฌ์ด๋ ์ดํ๋ฆฌ์ผ์ด์ , ๋ณด์์ ๊ฐ์ฅ ์์ ํ ์ ํ
- 1๋จ๊ณ : ์ธ๊ฐ ์๋ฒ๋ก๋ถํฐ code๋ฅผ ๋ฐ์์จ๋ค.
- 2๋จ๊ณ : code๋ฅผ ํตํด์ accessToken, refreshToken์ ๋ฐ์์จ๋ค. => ์ฌ๊ธฐ๊น์ง๊ฐ ์ธ๊ฐ ๋จ๊ณ
- 3๋จ๊ณ : accessToken์ ํตํด์ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ฐ์์จ๋ค. => ์ฌ๊ธฐ๋ถํฐ ์ธ์ฆ ๋จ๊ณ
- Client Credentials Grant Type : ํด๋ผ์ด์ธํธ ์๊ฒฉ ์ฆ๋ช ๊ถํ ๋ถ์ฌ ํ์ , ํ๋ฉด์ด ์๋ ์๋ฒ ์ดํ๋ฆฌ์ผ์ด์
- 1๋จ๊ณ : ์ธ๊ฐ ์๋ฒ๋ก๋ถํฐ code๋ฅผ ๋ฐ์์จ๋ค.
- 2๋จ๊ณ : code๋ฅผ ํตํด์ accessToken, refreshToken์ ๋ฐ์์จ๋ค. => ์ฌ๊ธฐ๊น์ง๊ฐ ์ธ๊ฐ ๋จ๊ณ
โ ์๋ฒ๋ผ๋ฆฌ์ ํต์ ๊ณผ์ ์์ ํ์ํ ํ์ ์ฌ์ฉ์์ ์ ๋ณด๋ ํ์ ์๋ค -> ์ฌ์ฉ์ ์ธ์ฆ ์ฒ๋ฆฌ์ ๋ํ ๊ฐ๋ ์ด ์์
-
Refresh Token Grant Type : ์๋ก๊ณ ์นจ ํ ํฐ ๋ถ์ฌ ํ์ , Authorization Code, Resource Owner Password Type์์ ์ง์
-
PKCE-enhanced Authorization Code Grant Type : PKCE ๊ถํ ์ฝ๋ ๋ถ์ฌ ํ์ , ์๋ฒ ์ฌ์ด๋ ์ดํ๋ฆฌ์ผ์ด์ , ๊ณต๊ฐ ํด๋ผ ์ดํ๋ฆฌ์ผ์ด์
โ 1๋จ๊ณ์์ ํ๋์ ๋งค๊ฐ๋ณ์๊ฐ ๋ ์กด์ฌํ๋ค. code(๊ธฐ์กด์ ์ฝ๋์๋ ๋ค๋ฅธ ์ฝ๋์) โ 2๋จ๊ณ์์ ์ฝ๋์ ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ฌํ๋ค. 2๊ฐ์ ๋งค๊ฐ๋ณ์๊ฐ ๋ ํ์(์ธ๊ฐ ์๋ฒ์ ๋น๊ต๋ฅผ ํตํด์ ๋์ผํ ํด๋ผ์ด์ธํธ์ผ ๊ฒฝ์ฐ์๋ง ํ์ฉ) ์ฌ๊ธฐ์ 1๋จ๊ณ์ ์ฒ๋ฆฌ ๊ณผ์ ์ด ๋ ๋์ด๋๋ค๊ณ ์๊ฐํ๋ฉด ๋๋ค.
OpenID Connect 1.0์ OAuth 2.0 ํ๋กํ ์ฝ ์์ ๊ตฌ์ถ๋ ID ๊ณ์ธต์ผ๋ก OAuth2.0์ ํ์ฅํ์ฌ ์ธ์ฆ ๋ฐฉ์์ ํ์คํํ OAuth2.0 ๊ธฐ๋ฐ์ ์ธ์ฆ ํ๋กํ ์ฝ์ด๋ค.
- scope ์ง์ ์ openid๋ฅผ ํฌํจํ๋ฉด OpenID Connect ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ฉฐ ์ธ์ฆ์ ๋ํ ์ ๋ณด๋ ID ํ ํฐ์ด๋ผ๋ JSON ์น ํ ํฐ์ผ๋ก ๋ฐํํ๋ค.
- OpenID Connect๋ ํด๋ผ์ด์ธํธ๊ฐ ์ฌ์ฉ์ ID๋ฅผ ํ์ธํ ์ ์๊ฒ ํ๋ ๋ณด์ ํ ํฐ์ธ ID Token์ ์ ๊ณตํ๋ค.
์ธ์ฆ์ ์ํ ํ๋กํ ์ฝ์ด๋ค. ์ค์ฝํ์ openid๊ฐ ํฌํจ๋๋ฉด ์ธ๊ฐ์๋ฒ์์ openid connect๋ฅผ ์ฌ์ฉํ๋ค.
OpenID Connect๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด ํ์ํ ๋ชจ๋ ์๋ ํฌ์ธํธ ๋ฐ ๊ณต๊ฐ ํค ์์น ์ ๋ณด๋ฅผ ํฌํจ ํ์ฌ OpenId ๊ณต๊ธ์์ ๊ตฌ์ฑ์ ๋ํ ํด๋ ์ ์งํฉ์ ๋ํ๋ธ๋ค.
์ธ๊ฐ ์๋ฒ์ ์ญํ ์ ์ ๊ณตํ๋ ์คํ์์ค๊ฐ ์๋๋ฐ KeyCloak์ด๋ผ๋ ๊ฑธ ๊ฐ์ง๊ณ ์ฌ์ฉํ ์ ์๋ค
- ์ค์น ๋ฐฉ๋ฒ dockerHub์ bitnami์์ ์ ์ํ keyCloak๋ฅผ ์ ๊ณตํ๋ ๊ฑธ ํ์ธํ ์ ์์๋๋ฐ ๊ณต์์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ๋ค.
version: '3.8'
services:
postgresql:
image: docker.io/bitnami/postgresql:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
- POSTGRESQL_USERNAME=bn_keycloak
- POSTGRESQL_DATABASE=bitnami_keycloak
volumes:
- 'postgresql_data:/bitnami/postgresql'
keycloak:
image: docker.io/bitnami/keycloak:latest
ports:
- "80:8080"
environment:
- KEYCLOAK_CREATE_ADMIN_USER=true
- KEYCLOAK_ADMIN_USER=admin
- KEYCLOAK_ADMIN_PASSWORD=admin
- KEYCLOAK_DATABASE_HOST=postgresql
- KEYCLOAK_DATABASE_NAME=bitnami_keycloak
- KEYCLOAK_DATABASE_USER=bn_keycloak
- KEYCLOAK_DATABASE_PASSWORD=
depends_on:
- postgresql
volumes:
- './mynewtheme:/opt/bitnami/keycloak/themes/mynewtheme'
volumes:
postgresql_data:
driver: local
์ด์ฒ๋ผ ์ธ๊ฐ์๋ฒ๋ฅผ ๊ฐ์ง๊ณ ํ ์คํธํ๊ณ ๋ก๊ทธ์ธ์ ์งํํด๋ณผ ์ ์๋ค.
security์์ oauth2๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ ์ฐ๋ฆฌ๋ yml ํ์ผ์ ํ์ํ ์ ๋ณด๋ค์ ๊ธฐ์ ํด์ฃผ๋ฉด ๋๋๋ฐ ์ด๋ป๊ฒ ์ ์ ์์๊น?
OAuth2ClientProperties
์ด ํด๋์ค์ ์์ธํ๊ฒ ๋์์๋ค ์ฌ๊ธฐ๋ฅผ ์ดํด๋ณด๋ฉด prefix๋ก spring.security.oauth2.client ์ด ๊ฐ์ ์ฃผ๊ณ ๊ฐ ์
ํ
์
private String provider;
/**
* Client ID for the registration.
*/
private String clientId;
/**
* Client secret of the registration.
*/
private String clientSecret;
/**
* Client authentication method. May be left blank when using a pre-defined
* provider.
*/
private String clientAuthenticationMethod;
/**
* Authorization grant type. May be left blank when using a pre-defined provider.
*/
private String authorizationGrantType;
/**
* Redirect URI. May be left blank when using a pre-defined provider.
*/
private String redirectUri;
/**
* Authorization scopes. When left blank the provider's default scopes, if any,
* will be used.
*/
private Set<String> scope;
์ด๋ฌํ ๊ฐ๋ค์ ์ ํ ํ ์ ์๋๊ฑธ ํ์ธํ ์ ์๋ค.
OAuth2ClientProperties ์ด๋ฅผ ์ฌ์ฉํ๋ ๊ณณ์ ์ฐพ์๋ณด๋ฉด
์ด๋ฐ ์ค์ ํด๋์ค๊ฐ ์๋๋ฐ ์ฌ๊ธฐ์ ์ค์ ์ ์ด๊ธฐํ ํด์ฃผ๋ ๋ชจ์ต์ ํ์ธํ ์ ์๋ค. ์ ๋ณด๋ฉด ClientRegistration์ด ๊ฐ์ ๋ฐ์ธ๋ฉํ๊ณ ์๋๋ฐ ์ฌ๊ธฐ ๋ค์ด๊ฐ๋ฉด
oauth2 ํต์ ์ ํ์ํ ๊ฐ๋ค์ด ๋ญ๋ญ๊ฐ ์๋์ง ํ์ธํ ์ ์์๋ค. ์ด ๊ฐ์ ๊ฐ์ง๊ณ ์ธ๊ฐ ์๋ฒ์ ํต์ ํ๋ ๊ฒ์ด๋ค.
์ฐ๋ฆฌ๊ฐ ์์ฃผ ์ฌ์ฉํ๋ ์ธ์ฆ ์๋ฒ ์ ๊ณต์๋ ์ด๋ป๊ฒ ํน์ ๊ฐ์ ์ ํ ์ํ๊ณ ์ฌ์ฉํ ์ ์๋๊ฑธ๊น?
public enum CommonOAuth2Provider {
GOOGLE {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, DEFAULT_REDIRECT_URL);
builder.scope("openid", "profile", "email");
builder.authorizationUri("https://accounts.google.com/o/oauth2/v2/auth");
builder.tokenUri("https://www.googleapis.com/oauth2/v4/token");
builder.jwkSetUri("https://www.googleapis.com/oauth2/v3/certs");
builder.issuerUri("https://accounts.google.com");
builder.userInfoUri("https://www.googleapis.com/oauth2/v3/userinfo");
builder.userNameAttributeName(IdTokenClaimNames.SUB);
builder.clientName("Google");
return builder;
}
},
GITHUB {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, DEFAULT_REDIRECT_URL);
builder.scope("read:user");
builder.authorizationUri("https://github.com/login/oauth/authorize");
builder.tokenUri("https://github.com/login/oauth/access_token");
builder.userInfoUri("https://api.github.com/user");
builder.userNameAttributeName("id");
builder.clientName("GitHub");
return builder;
}
},
FACEBOOK {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.CLIENT_SECRET_POST, DEFAULT_REDIRECT_URL);
builder.scope("public_profile", "email");
builder.authorizationUri("https://www.facebook.com/v2.8/dialog/oauth");
builder.tokenUri("https://graph.facebook.com/v2.8/oauth/access_token");
builder.userInfoUri("https://graph.facebook.com/me?fields=id,name,email");
builder.userNameAttributeName("id");
builder.clientName("Facebook");
return builder;
}
},
OKTA {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, DEFAULT_REDIRECT_URL);
builder.scope("openid", "profile", "email");
builder.userNameAttributeName(IdTokenClaimNames.SUB);
builder.clientName("Okta");
return builder;
}
};
private static final String DEFAULT_REDIRECT_URL = "{baseUrl}/{action}/oauth2/code/{registrationId}";
protected final ClientRegistration.Builder getBuilder(String registrationId, ClientAuthenticationMethod method,
String redirectUri) {
ClientRegistration.Builder builder = ClientRegistration.withRegistrationId(registrationId);
builder.clientAuthenticationMethod(method);
builder.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE);
builder.redirectUri(redirectUri);
return builder;
}
/**
* Create a new
* {@link org.springframework.security.oauth2.client.registration.ClientRegistration.Builder
* ClientRegistration.Builder} pre-configured with provider defaults.
* @param registrationId the registration-id used with the new builder
* @return a builder instance
*/
public abstract ClientRegistration.Builder getBuilder(String registrationId);
}
์ ์ฒ๋ผ Common Builder์ ์ ์ ๋์ด์๋ ๋ชจ์ต์ ํ์ธํ ์ ์์๋ค. ์ด๋ก ์ธํด์ yml์ ์ถ๊ฐ๋ก ์์ฑ์ ์ํด๋ ๋์์ด ๊ฐ๋ฅํ๋ค.
-
OAuth2๊ฐ ๋์ํ๊ฒ ๋๋ฉด ๋จผ์ ClientRegistration Repository ๋น์ด ์กด์ฌํ๋์ง ํ์ธํ๊ณ ์์ผ๋ฉด ClientRegistration Repository์ด ๋น์ ๋ง๋ค๊ฒ ๋๋ค.
-
์ดํ OAuth2ClientPropertiesMapper์ด ํด๋์ค๋ฅผ ํตํด์ ClientRegistrations ํด๋์ค๋ฅผ ๊ฐ์ ธ์ค๊ฒ ๋๋ค.

-
๊ทธ๋ฆฌ๊ณ ์ธ๊ฐ ์๋ฒ์ ๋ํ base url๋ฅผ ์ง์ ํ๊ฒ ๋๋ค. ์ด url์ ๊ฐ์ง๊ณ ํต์ ํด์ ์ธ๊ฐ ์๋ฒ์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๊ณ ์ค๊ฒ ๋๋ค.

2๊ฐ์ง์ ๋ฐฉ์์ด ์กด์ฌํ๋๋ฐ oidc ๋ฐฉ์๊ณผ oauth ๋ฐฉ์์ผ๋ก ๊ฐ์ ธ์จ๋ค.
์ถ๊ฐ์ ์ผ๋ก ์ด ClientRegistrations ํด๋์ค์์ ํ์ธํ ์ ์๋๋ฐ ClientAuthenticationMethod ์ด ํด๋์ค์ ๋ค์ด๊ฐ๋ฉด ์ด๋ ํ ํ์ ์ ์ง์ํ๋์ง ํ์ธํ ์ ์๋ค.
- RestTemplate๋ฅผ ํตํด์ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์์ MapConfiguration์ ํ๊ณ OIDCProviderMetadata๋ก ๋ณํํ๋ค. โ map์ ๊ฐ์ฒด๋ก ๋ณํํ๋ค๋ ๋ง
- ์ต์ข ์ ์ผ๋ก ClientRegistration๋ก ์์ฑ ๋ฐ ๋ฐํํ๊ฒ ๋๋ค.
โ ์ฌ๊ธฐ์ MapConfiguration์ ํ๋ค๊ณ ํ๋๋ฐ ์ฐ๋ฆฌ๊ฐ ๋ฐ๋ก application.yml์ ์ค์ ์ ์ํ ๊ฒฝ์ฐ์ ์๋์ผ๋ก ๋๋ ๊ฒ์ด๊ณ ๋ฐ๋ก ์ฐ๋ฆฌ๊ฐ ์ค์ ํ ๊ฐ์ด ์๋ค๋ฉด ๊ทธ ๊ฐ์ผ๋ก ๋ฎ์ด์ฐ๊ธฐ ๋๋ค.
๋ณธ์ธ์ yml ์ค์ ์ ๋ค์๊ณผ ๊ฐ์ด ์งํํ์๋ค.
server:
port: 8081
spring:
security:
oauth2:
client:
registration:
keycloak:
client-id: oauth2-client-app
client-secret: zlvRZaTJGI2dEPwDCXMJBWXL3HdQhpWe
client-name: client-app
redirect-uri: http://localhost:8081/login/oauth2/code/keycloak
authorization-grant-type: authorization_code
client-authentication-method: client_secret_basic
scope: openid, profile, email
provider:
keycloak:
authorization-uri: http://localhost/realms/oauth2/protocol/openid-connect/auth
token-uri: http://localhost/realms/oauth2/protocol/openid-connect/token
issuer-uri: http://localhost/realms/oauth2
user-info-uri: http://localhost/realms/oauth2/protocol/openid-connect/userinfo
jwk-set-uri: http://localhost/realms/oauth2/protocol/openid-connect/certs
user-name-attribute: preferred_username
๊ทผ๋ฐ ์ฌ๊ธฐ์ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ฐ์ง๊ณ ์ค๋ ๊ฐ๋ค์ด ๋ณด๋๊น ๋ค ์ธ๊ฐ ์๋ฒ์ ํต์ ์ ํตํด์ ๊ฐ์ง๊ณ ์ค๋ ๋ชจ์ต์ ํ์ธํ ์ ์์๋ค. ๊ทธ๋ผ ํ์์๋ ๊ฐ๊น์ง ์ ํ ํ ๊ฒ์ธ๋ฐ
server:
port: 8081
spring:
security:
oauth2:
client:
registration:
keycloak:
client-id: oauth2-client-app
client-secret: zlvRZaTJGI2dEPwDCXMJBWXL3HdQhpWe
redirect-uri: http://localhost:8081/login/oauth2/code/keycloak
scope: openid, profile, email
provider:
keycloak:
issuer-uri: http://localhost/realms/oauth2
์ด๋ ๊ฒ ๊ฐ๋ตํ ํ ์ ์์ ๊ฒ ๊ฐ๋ค.
์์ฒ๋ผ ๊ผญ ํ์ํ ์ ๋ณด๋ง ๋๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค. ์ด์์ด๋ ์ธ๊ฐ ์๋ฒ์ ์ฃผ์์ด๊ธฐ ๋๋ฌธ์ ํ์ํ ๊ฐ, ํด๋ผ์ด์ธํธ id, secret๊ฐ์ ์ธ๊ฐ ์๋ฒ๋ง๋ค ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ ํ์ํ ๊ฐ, redirect ๊ฐ๋ ํ์ ๊ฐ์ด๊ธฐ ๋๋ฌธ์ ์ด๋ ๊ฒ ์งํํ๊ณ scope๋ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ํ์๊ฐ์ด๊ธฐ ๋๋ฌธ์ ์ด๋ ๊ฒ ํด์ ์คํํด๋ณด๋ฉด
๋ด๊ฐ ์ค์ ํ ๊ฐ์ธ keycloak ๊ฐ๊ณผ ์ค์ ํ์ผ์ ๊ฐ์ด ๋ค์ด๊ฐ๋ ๋ชจ์ต์ ๋ณผ ์ ์์๊ณ ์ดํ ์ด์์ด๋ฅผ ํตํด์ ๋๋จธ์ง์ ๊ฐ๋ค์ ๊ฐ์ง๊ณ ์ค๋์ง ํ์ธํด๋ณด๋ฉด
์ด ์์ ์์ ์์์ด ๋๋๊น
๋ง์ง๋ง builder์ ๋ค์ด๊ฐ ์๋ ๊ฐ์ ํ์ธํด๋ณด๋ฉด yml์ ์ค์ ํด์ค ๊ฐ๋ค์ด ๋ค ๋ค์ด๊ฐ ์๋ ๋ชจ์ต์ ํ์ธํ ์ ์์๋ค. ์ฌ๊ธฐ์ ์ค์ํ ํฌ์ธํธ๋ ์ธ๊ฐ ์๋ฒ์ ์ฃผ์๋ฅผ ์ ์ด์ฃผ๊ฒ ๋๋ฉด ์ธ๊ฐ ์๋ฒ๋ฅผ ํตํด์
authorization-uri: http://localhost/realms/oauth2/protocol/openid-connect/auth
token-uri: http://localhost/realms/oauth2/protocol/openid-connect/token
user-info-uri: http://localhost/realms/oauth2/protocol/openid-connect/userinfo
jwk-set-uri: http://localhost/realms/oauth2/protocol/openid-connect/certs
user-name-attribute: preferred_username
์ด๋ฐ ๋ถ๊ฐ์ ์ธ ์ ๋ณด๋ค์ ๋ฐ์์ค๊ฒ ๋๋๋ฐ ์๊น์ ์ ์ธ๊ธํ Common oauth2 ์๋ฒ์ ๊ฒฝ์ฐ์ ์ด๋ฏธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์์ฑ์ด ๋์ด์๋๋ฐ provider์ ์ด์์ด๋ฅผ ์์ฑํ๊ฒ ๋๋ฉด ์ํด๋ ๋ ํต์ ์ ํ๋ฒ ๋ ํ๊ฒ ๋๋ค๋ ๊ฒ์ด๋ค.
๊ทธ๋ ๋ค๋ฉด ๋ง์ฝ ๊ธฐ๋ณธ ์ ๊ณต์๊ฐ ์๋ค๋ฉด provider ๊ฐ์ด ํ์ํ ๊น? common provider์ ๊ธฐ๋ณธ์ ์ธ ์ ๊ณต์ ๊ฐ์ด ์กด์ฌํ๋๋ฐ issuer-uri ๊ฐ์ ์ ํ ํ๋ฉด ์กด์ฌํ๋๋ฐ ํ๋ฒ ๋ ๋คํธ์ํฌ ํต์ ์ ํ๊ธฐ ๋๋ฌธ์ ์ด๋ ํ์ ์๋ค. ์ ๊ณต์๋ฅผ ์์ฑํ์ง ์๊ณ ์์ฑํ์ (redirect ๊ฐ๋ ํ์ ์๋ค. client id์ secret ๊ฐ๋ง ์์ผ๋ฉด ๋๋ค.)





