- gw 는 이름과 달리 여러가지 기능이 모여있는 모놀리식 서버이며 담당 개발자 1명이 개발하고 있습니다.
- gw 는 authn, authz 를 모두 하고 있습니다.
- 회원에 관련된 개발 요건이 백로그에 쌓이고 있으며, 요건 중에는 보안 요소도 있습니다.
- gw 의 부담을 줄이기 위해 회원에 관련된 기능을 분리하고 싶습니다.
$ cd docker
$ docker-compose up -d
client-user
realm 생성- 이메일 로그인 세팅
- Realm Settings > Login
- Email as username: ON
- Realm Settings > Login
- user attributes 세팅
- Realm Settings > User profile
- attributes 삭제: First Name, Last Name
- attributes 추가: name
- Realm Settings > User profile
- gateway 에서 사용할 client 생성
- Clients > Create
- Client ID:
gateway-service
- Client authentication: ON
- Authentication Flow Overrides: Standard flow, Direct access grants, Service account roles
- Client ID:
- Clients > Create
/http-client/keycloak
- 01_user_register.http
- 02_user_login.http
- 03_user_pwd_reset.http
- 04_access_key_verify_by_public_key.http
- 05_access_token_from_refresh_token.http
- keycloak-admin-client sdk 로 개발
- townhall 은 admin client 의 역할을 하고, gateway-service 는 user client 의 역할을 합니다.
client-user
realm 선택- townhall 에서 사용할 client 생성
- Clients > Create
- Client ID:
townhall
- Client authentication: ON
- Authentication Flow Overrides: Standard flow, Direct access grants, Service account roles
- Client ID:
gateway-service
client 에서 Service account roles 제거
- Clients > Create
- logging enabled
- Realm Settings > Events > User events settings
- Save events: ON
- Expire events: 30 days
- Realm Settings > Events > User events settings
- 회원가입
POST /api/v1/client-user/users
- 비밀번호 변경
PUT /api/v1/client-user/users/{userId}/password
- 프로젝트명 overload-admin 로 변경
- 사내에서 사용하기 위한 testbed 용도이기에 이름을 변경합니다.
- team 정보를 user profile 에서 관리하기
- user attributes 세팅
- Realm Settings > User profile
- attributes 추가: team
- Enabled when: Scopes are requested
- Realm Settings > User profile
- client scope 추가
- Client scopes > Create client scope
- Name: team
- Type: Optional
- Include in token scope: ON
- save 후 Mappers 선택
- Configure a new mapper > User Attribute
- Name: team
- User Attribute: team
- Token Client Name: team
- Claim Json Type: JSON
- Configure a new mapper > User Attribute
- Client scopes > Create client scope
- client 에 scope 적용
- Clients >
gateway-service
선택 - Client scopes > Add client scope
- Optional 로 Add
- Clients >
- team 은 Optional 이기에 기본적으로 노출되지 않습니다.
- scope 를 명시하면 노출 됩니다.
POST {{base_url}}/realms/client-user/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded
username = dan@sionic.ai &
password = password &
grant_type = password &
client_id = {{client_id}} &
client_secret = {{client_secret}} &
scope = team