ã¯ããã«
ä»å¹´æå¾ã®ã¢ããã³ãã«ã¬ã³ãã¼ãæ å½ãã¾ããã³ã³ãµã«ã¿ã³ãã®éåã§ããã¯ãªã¹ãã¹ã¨ãããã¨ã§ãµã³ã¿ã¯ãã¼ã¹ããã¬ã¼ã³ããæã£ã¦ããã家åºããããã¨ãæãã¾ãããã»ãã¥ãªãã£ã¯ä¸å ¨ã§ãããããOpenShift ã® Identity Provider ã« htpasswd ãã使ãã®æ¹ãããã£ãããããããã¾ããããOpenShift ãããã»ãã¥ã¢ã«ãã¦å®å¿å®å ¨ãªå¹´æ«å¹´å§ãéããã¾ãããã
ç®æ¬¡
- ã¯ããã«
- ç®æ¬¡
- Identity Provider
- ç°å¢
- Red Hat Singl Sign-on (KeyCloak) ã®è¨å®
- Identity Provider ã®è¨å®
- ãã°ã¤ã³ã®æ¤è¨¼
- çµããã«
Identity Provider
OpenShift 4.x ã§ã¯æ§ç¯å¾ã«ããã©ã«ãã§ã¯ã kubeadmin
ã¦ã¼ã¶ã¼ãå©ç¨ã§ãã¾ããã¯ã©ã¹ã¿ã¼ç®¡çè
権é (cluster-admin) ãæã¤ãã®ã¦ã¼ã¶ã¼ã ãã§ãæ®æ®µã®æ¤è¨¼ã¯è¡ãªãã¾ãããã¦ã¼ã¶ã¼åããã¹ã¦ã® OpenShift ã¯ã©ã¹ã¿ã¼ã§åºå®ã§ãããã¨ãããã¹ã¯ã¼ããå¤æ´ã§ããªããã¨ãã Identity Provider è¨å®å¾ã«ã¯ã©ã¹ã¿ã¼ç®¡çè
権éãæã¤ã¦ã¼ã¶ã¼ãç»é²ããæç¹ã§åé¤ãããã¨ãæ¨å¥¨ããã¦ãã¾ãã
kubeadmin
ã¯ãã¦ãããOpenShift ã§ã¯æ§ã
㪠Identity Provider ãå©ç¨ã§ãã¾ããã©ã¡ãã® Identity Provider ãã使ãã§ãããããLDAP ãå©ç¨ããããAzure AD ãªã©ã¨ OpenIDConnect ã§æ¥ç¶ããã¦ããæ¹ããããã¨æãã¾ãã
ä»åã¯çä½èªè¨¼ãå©ç¨ã OpenShift ã¸ãã°ã¤ã³ãããã¨ãå®ç¾ããããã«ãRed Hat Single Sign-on (RHSSO) ãå©ç¨ãã¾ããRHSSO 㯠OpenShift ã® Identity Provider ã¨ãã¦å©ç¨ã§ããã¾ã Operator ãå©ç¨ãã¦ã¤ã³ã¹ãã¼ã«ãã¨ãã§ãã¾ãã ä»å¹´ã®ï¼æããã« 7.6 ã GA ã«ãªããWebAuthn ãå©ç¨ã§ããããã«ãªãã¾ãããããã«ãããFIDO2è¦æ ¼ã«å¯¾å¿ããOS/ãã©ã¦ã¶(ã¹ãã¼ããã©ã¼ã³å«ã)ã§ãçä½èªè¨¼ãå®ç¾ã§ãã¾ãã ä»åã¯ãã®è¨äºã§ç´¹ä»ããã¦ããæ©è½ãå©ç¨ãã¤ã¤ OpenShift ã«ãã°ã¤ã³ã§ããããã«ãããã¨æãã¾ãã
ç°å¢
ä»åã¯ä»¥ä¸ã®ç°å¢ã§æ¤è¨¼ãè¡ãã¾ãã
- ä½æ¥ç«¯æ«ï¼ Macbook Pro (Montery)
- OpenShift ãã¼ã¸ã§ã³ï¼4.11
- RHSSO ãã¼ã¸ã§ã³ï¼7.6
Red Hat Singl Sign-on (KeyCloak) ã®è¨å®
Operator ã®ã¤ã³ã¹ãã¼ã«
OperatorHub ãã RHSSO ãã¤ã³ã¹ãã¼ã«ãã¾ããã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ GUI ã CLI ã©ã¡ãã§ãæ§ãã¾ãããä»åã¯è¦ãããããã« GUI ã§å°å ¥ãã¾ããã
ä»å㯠rhsso
ããã¸ã§ã¯ãã« Operator ãå°å
¥ãã¾ããchannel 㯠stable
ãå©ç¨ãã¾ããUpdate ã¯èªåãé¸æãã¾ãã
Install
ãã¿ã³ãã¯ãªãã¯ãããã¨ã¯ãã¤ã³ã¹ãã¼ã«ãå®äºããã¾ã§å¾
ã¡ã¾ãããã
KeyCloak ã¤ã³ã¹ã¿ã³ã¹ã®ãããã¤
OpenShift Web Console ã® Operators - Installed operators ãéãã¨ãRed Hat Single Sign-on ãã¤ã³ã¹ãã¼ã«ããã¦ãããã¨ã確èªã§ãã¾ãã®ã§ã該å½ã® Operator ãã¯ãªãã¯ãã¾ãã
API ã®ä¸è¦§ãã Keycloak
ãé¸æããYaml ç·¨éç»é¢ãéãã¾ãã
KeyCloak ã® Custom Resource ãå©ç¨ãããã¨ã§åé·æ§ã®ç¢ºä¿ãå¤é¨DBãå©ç¨ããäºãã§ãã¾ãããç®çã¯çä½èªè¨¼ã®ãããåé·æ§ãªã©ã¯ç¡è¦ãã¦é²ãã¾ããè¨å®å 容ã¯æ¬¡ã®ã¨ããã§ãã
ãããã¤å®äºå¾ãè¨å®éãã®å
容ã®å ´åãrhsso
ããã¸ã§ã¯ãé
ä¸ã« credential-example-keycloak
ã¨ããååã® Secret ãä½æããã¦ãããã¨ã確èªã§ãã¾ãã®ã§ãKeyCloak ã® Admin ã®ãã¹ã¯ã¼ãã確èªãã¾ãã
KeyCloak ã®è¨å®
Administration Console ã«ãã°ã¤ã³ãã¾ããå ç¨ç¢ºèªãã Admin ã®ãã¹ã¯ã¼ããå©ç¨ãã¦ã³ã³ã½ã¼ã«ã«ãã°ã¤ã³ãã¾ãã
Realm ã®ä½æ
ãµã³ãã«ã®ãããRealm ã®åå㯠test
ã¨ãã¦ã¾ãã
Realm ã®è¨å®
WebAuthn Passwordless Policy ã®è¨å®
Realm ä½æå¾ãAuthentication ã®è¨å®ãè¡ãã¾ãã[Configure] - [Authentication] ãéãã¾ãã
ã¡ãã¥ã¼ãã¼ãã [WebAuthn Passwordless Policy] ãéããUser Verification Requirement
ã required
ã«è¨å®ã Save
ãã [Required Actions] ã«ç§»åãã¾ãã
Required Actions ã®è¨å®
[Required Actions] ã«ã¦ãRegister
ãæ¼ãã¦ãWebauthn Register Passwordless
ã追å ãã¾ãããã®å¾ãWebauthn Register Passwordless ã® Default Action ãæå¹ã«ãã¾ããããã«ãããæ°è¦ã¦ã¼ã¶ã¼ãååãã°ã¤ã³æã« Webauthn ã®ç»é²ãæ±ããããããã«ãªãã¾ãã
Flows ã®è¨å®
[Flows] ã¿ããéãã¨ãBrowser
ã® Flow ãéãã¦ãããã¨æãã¾ãã®ã§ãå³ã«ãã Copy
ãæ¼ãã¦ãBrowser
ããã¼ã¹ã«ããæ°è¦ã® Authentication Flow ãä½æãã¾ããããã¼å㯠Webauthen
ã¨ãã¾ãã
Flow ãä¿®æ£ãã¦ããã¾ããä»åã®èªè¨¼ããã¼ã¯ãã¦ã¼ã¶ã¼åå ¥åå¾ãã¦ã¼ã¶ã¼èªè¨¼ã¨ãã¦ããã¹ã¯ã¼ããæç´èªè¨¼ã«ãããã°ã¤ã³ã§ããããã«ãã¾ããã¾ãã¯ã¦ã¼ã¶ã¼åã¨ãã¹ã¯ã¼ãèªè¨¼ã®ãã©ã¼ã ãåé¤ããã¦ã¼ã¶ã¼åã®ãã©ã¼ã ã«å·®ãæ¿ãã¾ãã
è¨å®ã®ç´°ããé¨åã¯ä»¥ä¸ã®è£½åããã¥ã¡ã³ããåç §ãã¦ããã ããã°ã¨æãã¾ãã access.redhat.com
è¨å®ããå 容ã¯æ¬¡ã®ã¨ããã§ãã
- Username ã®ãã©ã¼ã ã追å ï¼ãã¨ãã¨ãã£ãUsernameãPasswordã®ãã©ã¼ã ã¯åé¤ï¼
- ãã¹ã¯ã¼ãèªè¨¼ã Passwordless Authenticator ããé¸æããããã¼ã追å
- ä¸è¨ããã¼ã« Passwordless ã® Execution 㨠Password ãã©ã¼ã ã®ããã¼ã追å
ããã¼ã®è¨å®ã¯ããã¾ã§ã§ãã
Bindings ã®è¨å®
[Bindings] ã¿ããéããè¨å®ãã Flow ã® [webauthn] ã Browser ã®èªè¨¼ããã¼ã§å©ç¨ããããè¨å®ãã¾ããBrowser Flow
ã®ãã«ãã¦ã³ãã Webauthen
ãé¸æããSave
ãã¿ã³ãã¯ãªãã¯ãã¦ãã ããã
ããã¾ã§ã§ãWebauthn ã«é¢ããè¨å®ã¯å®äºã§ãã
Client ã®ä½æã¨è¨å®
ã¡ãã¥ã¼ãã Clients ãé¸æããCreate
ãã¿ã³ãæ¼ãã¦ãã ãããClient åã« idp-4-ocp ãæå®ããClient Protocol
㯠openid-connect
ãé¸æããã¦ãããã¨ã確èªã㦠Save ãã¯ãªãã¯ãã¦ãã ããã
client idp-4-ocp
ãä½æãããã¨è¨å®ç»é¢ãéãã¾ããSetting
ã® Access Type
ã confidential
ã«ãValidation URL
ã« https://oauth-openshift.apps.<cluster_name>.<domain>/oauth2callback/keycloak
ãè¨å®ãã¾ã
cluster_name>.keycloak
㯠OpenShift å´ã§ç»é²ãã Identity Provider ã®å称ã§ããè¦ä»¶ã«åããã¦å¤æ´ãã¦ãæ§ãã¾ãããè¨å®å¾ save
ãã¾ãã
次ã«ãCredentials
ã¿ããéããSecret ãè¨é²ãã¾ããå¥é Identity Provider ã®è¨å®æã«å©ç¨ãã¾ãã
ã¦ã¼ã¶ã¼ã®è¿½å
OpenShift ã«ãã°ã¤ã³ããã¦ã¼ã¶ã¼ã追å ãã¾ãã Test Realm ã® [Manage] ã® [Users] ãã¯ãªãã¯ãã¾ããAdd user
ãã¿ã³ãå³å´ã«ããã®ã§ãã¯ãªãã¯ãã¦ã¦ã¼ã¶ã¼ã追å ãã¾ãããµã³ãã«ã®ããã¦ã¼ã¶ã¼åã sample
ã¨ãã¦ç»é²ãã¾ãã
ã¦ã¼ã¶ã¼ç»é²å¾ãç»é²ããã¦ã¼ã¶ã¼ã® Credentails
ãéãã¨ãã¹ã¯ã¼ããè¨å®ã§ãã¾ãã®ã§ããã¹ã¯ã¼ããè¨å®ãã¦ãã°ã¤ã³ãã§ããããã«ãã¾ãã
Identity Provider ã®è¨å®
ããããè¨å®ã大詰ãã§ããKeyCloak ã¤ã³ã¹ã¿ã³ã¹ã OpenShift ã® Identity Provider ã¨ãã¦å©ç¨ã§ããããã«è¨å®ãã¾ããã¾ãã¯ãOpenShift ã KeyCloak ã¸ã¢ã¯ã»ã¹ããã¨ãã® Secret ãè¨å®ãã¾ãã
è¨å®æºå
Secret ä½æã§ã¯ãå
ç¨è¨é²ãã idp-4-ocp
ã® Credential ãæå®ãã¾ãã${Credential} ãèªã¿æ¿ãã¦ãã ããã
$ oc -n openshift-config create secret generic keycloak-client-secret --from-literal=clientSecret=${Credential}
RHSSO ã OpenShift ã® Route ã«ããã©ã«ãã§è¨å®ããã証ææ¸ãä¿¡é ¼æ¸ã¿ã¨ããããã«ãCA 証ææ¸ãåå¾ããConfigMap ã¨ãã¦ç»é²ãã¾ããOpenShift ã®è¨¼ææ¸ãæ£è¦ã®ãã³ãã¼ã«ããè³¼å ¥æ¸ã¿ã®ãã®ã®å ´åã以ä¸ã®CA証ææ¸ã®åå¾ãConfigMap ã¨ãã¦ã®ç»é²ãIdentity Provider ç»é²æã® ca ãã£ã¼ã«ãã®æå®ã¯ä¸è¦ã¨ãªãã¾ãã
CA 証ææ¸ã®åå¾
$ oc -n openshift-ingress-operator get secret router-ca -o jsonpath="{ .data.tls.crt }" | base64 -d -i > ca.crt
ConfigMap ã¨ãã¦ç»é²
$ oc -n openshift-config create cm keycloak-ca --from-file=ca.crt
OpenShift OAuth ã®è¨å®ã
OAuth Custom Resource ãããIdentity Provider ãè¨å®ãã¾ãã以ä¸ã®ã³ãã³ããå®è¡ãã¾ããissuer
㯠KeyCloak ã¤ã³ã¹ã¿ã³ã¹ã®ã¢ã¯ã»ã¹æ
å ±ãæå®ãã¾ããRealm
å㯠test
ã¨ãªã£ã¦ãã¾ããç°å¢ã«åããã¦å¤æ´ãã¦ãã ããã
$ cat <<EOF | oc apply -f - apiVersion: config.openshift.io/v1 kind: OAuth metadata: name: cluster spec: identityProviders: - mappingMethod: claim name: keycloak openID: ca: name: keycloak-ca claims: email: - email name: - name preferredUsername: - preferred_username clientID: idp-4-ocp clientSecret: name: keycloak-client-secret issuer: https://keycloak-rhsso.apps.ocp4.example.com/auth/realms/test type: OpenID EOF
ããã¾ã§ã§ãidentity Provider ã®è¨å®ã¯å®äºã§ããè¨å®ã®åæ ã«ã¯æ°åãããã®ã§å°ãã¾ã¡ã¾ãã
ãã°ã¤ã³ã®æ¤è¨¼
Identity Provider ãæ£å¸¸ã«è¨å®ãããã¨ãOpenShift Web Console ã®ãã°ã¤ã³ç»é¢ã次ã®ããã«ãªãã¾ããkeycloak
ãã¯ãªãã¯ãã¦ç»é²ããã¦ã¼ã¶ã¼ã§ãã°ã¤ã³ãã¾ãã
sample ã¦ã¼ã¶ã¼ã§ Sign In
ãã¾ãããã¹ã¯ã¼ãã§ãµã¤ã³ã¤ã³ãã㨠Security Key ã®ç»é²ã¨ãã¦ãçä½èªè¨¼ç»é²ãè¡ããããã«ãªãã¾ãã
èªè¨¼ãå®äºããã¨ãOpenShift ã®ãã°ã¤ã³ãå®äºãã¾ãããã ããã§ã¯ãã¹ã¯ã¼ãèªè¨¼ã§ãã°ã¤ã³ãã¦ãããããä¸æ¦ãã°ã¢ã¦ããã¾ããOpenShift ããã®ãã°ã¤ã³ã ãã§ã¯å®å
¨ã«ãã°ã¤ã³ãããã¨ã«ãªããªãå ´åããããããRHSSO ããããã°ã¢ã¦ããã¦ããã¾ãã
ä»ç°å¢ã§ã¯ã以ä¸ã«ã¢ã¯ã»ã¹ããã¨ãsample
ã¦ã¼ã¶ã¼ã§ãã°ã¤ã³ãããã¨ã«ãªã£ã¦ããããããã°ã¢ã¦ããã¾ããã
https://keycloak-rhsso.apps.ocp4.example.com/auth/realms/test/account/
æ¹ãã¦ããã°ã¤ã³ãã¦ã¿ã¾ããWeb Console ã® keycloak
ãã¯ãªãã¯ãã¾ããå
ã»ã©ã¨ç°ãªãããã¹ã¯ã¼ãå
¥åã®ä¸ã« Try Another Way
ã¨ãããªã³ã¯ãè¦ãã¾ãã®ã§ã¯ãªãã¯ãã¾ãã
ããã¨ããã¹ã¯ã¼ãã Security Key èªè¨¼ãé¸æããç»é¢ã表示ããã¾ããããã§ãSecurity Key ãé¸æãã¾ãã
Google Chrome ãã Touch ID ãå©ç¨ããèªè¨¼ã®ç¢ºèªããããã¢ããã§è¡¨ç¤ºããã¾ãã
ã¹ãã£ã³ãè¡ãã¨ããã°ã¤ã³ãå®äºããOpenShift Web Console ã表示ããããã¨ã確èªã§ãã¾ãã
çµããã«
Red Hat Single Sign-on ãå©ç¨ãããã¨ã§ãOpenShift ã«çä½èªè¨¼ãå©ç¨ãã¦ãã°ã¤ã³ã§ãããã¨ã確èªã§ãã¾ãããããã§å®å¿ãã¦å¹´ãè¶ããã¨ãã§ãããã§ããæ¥å¹´ãã»ãã¥ã¢ãªä¸å¹´ã«ãã¾ãããã