Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Key Cloak

Key Cloak 설치

  • 사전 조건 : Docker 환경 구성

터미널에서 아래 명령어 입력

docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:11.0.0

기본 8080 포트 구성. 포트 변경 필요시 해당 부분 변경 <container port>:<host port>

관리 콘솔 로그인

1. http://<IP주소 or localhost>:8080 접속

2. Administration console 클릭 한 후 admin 계정으로 로그인(keycloak 컨테이너 실행 시 입력한 ID/PW)

영역(realm) 생성

1. 화면 좌측 상단 Master 영역 > “Add realm” 버튼 클릭

2. 영역 이름 입력 > 활성화 enable on > “Create” 버튼 클릭

Client 생성

1. Clients > “Create” 버튼 클릭

2. 각 키값 입력

Key

Value

Client ID *

gitlab.example.com

Client Protocol

saml

Client SAML Endpoint

https://gitlab.example.com/users/auth/saml/callback

3. Setting Tab 설정

Key

Value

Client ID

gitlab.example.com

Name

Example GItlab

Description

some description

Enabled

ON

Consent Required

OFF

Login Theme

base

Client Protocol

saml

Include AuthnStatement

ON

Include OneTimeUse Condition

OFF

Sign Documents

ON

Optimize REDIRECT signing key lookup

OFF

Sign Assertions

ON

Signature Algorithm

RSA_SHA26

SAML Signature Key Name

KEY_ID

Canonicalization Method

EXCLUSIVE

Encrypt Assertions

OFF

Client Signature Required

ON

Force POST Binding

ON

Front Channel Logout

ON

Force Name ID Format

OFF

Name ID Format

persistant

Root URL

https://gitlab.example.com

Valid Redirect URIs

https://gitlab.example.com/users/auth/saml/callback

Base URL

/

Master SAML Processing URL

https://gitlab.example.com/users/auth/saml/callback

IDP Initiated SSO URL Name

IDP Initiated SSO Relay State

####Fine Grain SAML Endpoint Configuration:

Key

Value

Assertion Consumer Service POST Binding URL

https://gitlab.example.com/users/auth/saml/callback

Assertion Consumer Service Redirect Binding URL

Logout Service POST Binding URL

Logout Service Redirect Binding URL

4. Roles Tab 설정

Role 이름

Composite

gitlab.example.com:access

false

gitlab.example.com:external

false

5. Mappers Tab 설정

Create 버튼 클릭하여 아래와 같이 생성

  • Name: name

    • Mapper Type: User Property

    • Property: Username

    • Friendly Name: Username

    • SAML Attribute Name: name

    • SAML Attribute NameFormat: Basic

  • Name: email

    • Mapper Type: User Property

    • Property: Email

    • Friendly Name: Email

    • SAML Attribute Name: email

    • SAML Attribute NameFormat: Basic

  • Name: first_name

    • Mapper Type: User Property

    • Property: FirstName

    • Friendly Name: First Name

    • SAML Attribute Name: first_name

    • SAML Attribute NameFormat: Basic

  • Name: last_name

    • Mapper Type: User Property

    • Property: LastName

    • Friendly Name: Last Name

    • SAML Attribute Name: name

    • SAML Attribute NameFormat: Basic

  • Name: roles

    • Mapper Type: Role list

    • Role attribute name: roles

    • Friendly Name: Roles

    • SAML Attribute NameFormat: Basic

    • Single Role Attribute: On

idp Fingerprint 생성

1. Realm Settings > Keys > RSA256 > Certificate 복사

2. https://www.samltool.com/fingerprint.php 접속하여 fingerprint 생성

<BEGIN CERTIFICATE><END CERTIFICATE> 형식으로 입력

Gitlab에서 지원하는 알고리즘은 sha1이므로 해당 알고리즘 선택 후 fingerprint 생성

GitLab

SAML 설정

1. gitlab.rb 수정

gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_saml_user'] = true
gitlab_rails['omniauth_providers'] = [
   {
     "name" => "saml",
     "label" => "<보여지는 버튼 이름>",
     "groups_attribute" => "roles",
     "external_groups" => ['<roles tab에 구성한 external 이름'],
     "args" => {
      assertion_consumer_service_url: '<gitlab url>/users/auth/saml/callback',
      idp_cert_fingerprint: '생성한 fingerprint',
      idp_sso_target_url: '<keycloak url>/auth/realms/<realm 이름>/protocol/saml/clients/<client 이름>',
      allowed_clock_drift: 5,
      issuer: '<client 이름>',
      attribute_statements: {
           first_name: ['first_name'],
           last_name: ['last_name'],
           name: ['name'],
           username: ['name'],
           email: ['email'] },
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      }
  }
]

2. GitLab 재구성

$ gitlab-ctl reconfigure

3. GitLab 로그인 확인

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.