Dex에 Google 연결하기
OAuth client 생성
- https://console.cloud.google.com/
- APIs & Services -> Credentials 페이지로 이동합니다.
Create credentials->OAuth client ID를 클릭합니다.Application type으로 Web application을 선택합니다.- Name, Authorized redirect URIs를 입력합니다.
Create를 클릭합니다.
설정
dex-values.yaml
config:
connectors:
- type: google
id: google
name: Google
config:
clientID: <clientID>
clientSecret: <clientSecret>
redirectURI: <issuerURI>/callback
promptType: ""
groups 가져오기
Service account 생성
- https://console.cloud.google.com/
- IAM & Admin -> Service Accounts 페이지로 이동합니다.
Create service account를 클릭합니다.- Service account name을 입력하고
Create and continue를 클릭합니다. Done을 클릭합니다.
Credential 생성
- https://console.cloud.google.com/
- IAM & Admin -> Service Accounts 페이지로 이동합니다.
- 생성한 Service account를 클릭합니다.
- Keys 탭으로 이동합니다.
Add Key->Create new key를 클릭합니다.- JSON을 선택 후
Create를 클릭합니다.
생성하면 자동으로 JSON 파일이 다운로드됩니다.
Domain-wide delegation 설정
- https://console.cloud.google.com/
- IAM & Admin -> Service Accounts 페이지로 이동합니다.
- 생성한 Service account를 클릭합니다.
Advanced settings를 확장합니다.- Client ID를 복사합니다.
View Google Workspace Admin Console을 클릭합니다.(super administrator)- Security -> Access and data control -> API controls 페이지로 접속합니다.
MANAGE DOMAIN WIDE DELEGATION을 클릭합니다.Add new를 클릭한 후 복사한 Client ID를 입력합니다.- OAuth scopes에
https://www.googleapis.com/auth/admin.directory.group.readonly를 입력합니다. AUTHORIZE를 클릭합니다.
Admin SDK API 활성화
- https://console.cloud.google.com/
- APIs & Services -> Enabled APIs & services 페이지로 이동합니다.
Enable APIs and services를 클릭합니다.- Admin SDK를 검색합니다.
Admin SDK API를 클릭합니다.Enable을 클릭합니다.
Admin Email 설정
- https://admin.google.com/
- Account -> Admin roles 페이지로 이동합니다.
Groups Reader를 클릭합니다.- 사용할 Email을 추가합니다.
설정 적용하기
apiVersion: v1
kind: Secret
metadata:
name: dex-google-service-account
namespace: dex
type: Opaque
data:
googleAuth.json: <googleAuth.json | base64 | tr -d '\n'>
dex-values.yaml
config:
connectors:
- type: google
config:
serviceAccountFilePath: /etc/dex/google-auth/googleAuth.json
domainToAdminEmail:
<domain>: <adminEmail>
volumes:
- name: google-auth
secret:
secretName: dex-google-service-account
volumeMounts:
- name: google-auth
mountPath: /etc/dex/google-auth