ã«ããã·ã®èªè¨¼èªå¯ã¦ãããã§ã½ããã¦ã§ã¢ã¨ã³ã¸ãã¢ããã£ã¦ãããã¢=ãã¦ã§ãã
å
æ¥ãéå»ã«å¼ç¤¾ã§è¡ã£ãå
±éIDåºç¤æ§ç¯ããã¸ã§ã¯ãã«é¢ããããã°è¨äºãå
¬éããã®ã§ããããèªã¿ããã ããã§ããããï¼ã¾ã èªãã§ããªãæ¹ã¯æ¯éãä¸èªãã ããï¼
スタートアップがゼロから作る共通ID基盤:立ち上げ〜ID統合まで道のり(前編) - カミナシ エンジニアブログ
スタートアップがゼロから作る共通ID基盤:ID統合のその先へ(後編) - カミナシ エンジニアブログ
ãã¦ãä»åã¯ååã«ãèªè¨¼èªå¯å®å
¨åå¿è
ã ã£ãèªåãå¦ä½ã«ãã¦IDåºç¤æ§ç¯ããã¸ã§ã¯ãå®éã«è²¢ç®ããã«è³ã£ãããã¨ããè¦ç¹ã§åãã©ã®ããã«èªè¨¼èªå¯ã®å¦ç¿ããã¦ãããã«ã¤ãã¦ã話ããã¾ããããã¦å¾åã¯ãä»ããå¦ç¿ãç´ããªãã©ãããããã¨ãããã¼ãã§ç¾æç¹ã§åã®èããæéã®ãç¥ã®é«ééè·¯ããç´¹ä»ãã¦ã¿ããã¨æãã¾ãã
ååã®è¨äºãå°ã硬ãã®æãã«ãªã£ã¦ãã¾ã£ãã®ã§ãä»åã¯çæéã§èªããè¨äºã«ä»ä¸ããã¤ããã§ãã
èªè¨¼èªå¯ã®ä¸çã«å°ãã§ãèå³ãããæ¹ã«ã¯æ¯éèªãã§ããã ãããã§ãï¼
â»ãèªè¨¼èªå¯å¦ç¿ã®ããããã¨å¤§ãã謳ã£ã¦ãã¾ãããæ¬è¨äºã¯OAuth2.0, OpenID Connectã«ãã©ã¼ã«ã¹ããå 容ã«ãªã£ã¦ãã¾ã
ç§ãéã£ãé
1. ã¨ãããã OpenID Connect ã調ã¹ã
ã«ããã·ã®èªè¨¼èªå¯ã¦ãããã«ã¯ããã¡ããç§ã®ãããªã«ããã·ã«æ¥ã¦ã¯ããã¦èªè¨¼èªå¯ãå¦ãã ã¡ã³ãã¼ã ãã§ã¯ãªããèªè¨¼èªå¯ã«ç²¾éããã¡ã³ãã¼(@manaty0226)ãå¨ç±ãã¦ãã¾ãã
IDåºç¤ãä½ãå§ãã彿ãå½¼ã¯ããè¨ãã¾ããããããã OIDC ã§ããããã彿ã®å㯠OIDC ã¨ããã¯ã¼ããä½ã¨ãªãèãããã¨ããããããã§ããã®ä¸èº«ã¯ä½ãç¥ãã¾ããã§ããããã¨ããããããªãã»ã©ã OIDC ã§ããï¼ãã¿ãããªåå¿ãããæ°ããã¾ãã
ãä¸å¿ç¥ã£ã¦ã¾ããã¿ãããªåå¿ããã¦ãã¾ã£ããããæ¥ãã§ OIDC ã®ãã¨ã調ã¹ãªãã¨ãããªããªãã¾ããã
ä½ãè¨ã£ã¦ããåãããªãã OpenID Connect Core 1.0
ãã®ã¾ã¾ã§ã¯ã¾ããã¨èããåã¯ã¾ã OpenID Connect Core 1.0 ãèªã¿ã¾ãããããã¨ãããªããããªãã¨ãæ¸ãã¦ããã¾ãã
OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0Â [RFC6749]Â protocol.
å«ãªäºæããã¾ãããããã¼ãã㯠OAuth2.0 ã®ãã¨ãç¥ããªãã¨èªããªããã¤ããªï¼ãããã®äºæã¯ããã«ç¢ºä¿¡ã«å¤ããã¾ãã
3.1 Authentication using the Authorization Code Flow
ãAuthorization Code Flowãã£ã¦ä½ãããã
ã©ããã RFC6749 ãå
ã«èªã¾ãªãã¨ãããªãã¿ããã§ããããããåã«ã¯æ©æ¥ã«ãä¸å¿ç¥ã£ã¦ã¾ãããªç¶æ
ã«ãªããªãã¨ãããªããã¬ãã·ã£ã¼ãããã£ã¦ãã¾ããã
ããã§åãã¨ã£ã鏿ã¯ããæ¥æ¬èªã§æ¸ãããããã°è¨äºãªã©ã§ OAuth ã®ç¥èãè£å®ãã¤ã¤ã OIDC ã®ä»æ§ãçè§£ãããã¨ããæ¹æ³ã§ããã
ãªãã¨ãªãåãããã©ããªãã¨ãªãåãããªã
æ§ã
ãªããã°ãåç
§ã㦠OAuth ã®åããã¼ãçè§£ãã¾ããã以åç¥ããªãã£ããAuthorization Code Flowãã®ã·ã¼ã±ã³ã¹å³ã¯å®å
¨ã«é ã«å
¥ã£ã¦ãã¾ããã§ã¯ãæ¹ã㦠OpenID Connect Core 1.0 ã¨å¯¾å³ãã¾ãããã
ããã¼ããªãã¨ãªãåãããã©ããªãã¨ãªãåãããªããªï¼ï¼ï¼ãã
OAuth ã®ãã¨ã調ã¹ãã¨è¨ã£ã¦ãããã ã·ã¼ã±ã³ã¹ã丸æè¨ããã ãã§ããnonce ã£ã¦ä½ï¼ããPKCEï¼ãããªãã§ã¤ã³ããªã·ããããã¼ã¯ãã¡ãªã®ï¼ãã¿ãããªçåãå¸¸ã«æº¢ãã¦ãã¾ãããè©°ã¾ãã¨ããããªã OAuth ããã®ãããªã·ã¼ã±ã³ã¹ã«ãªã£ãã®ããã¨ããæ¬è³ªé¨åã¸ã®çè§£ãæ¬ ãã¦ããç¶æ
ã§ãã
èªè¨¼åºç¤ã®ã¨ããæ©è½ã«é¢ãã¦ãç»æçãªä»çµã¿ãæãã¤ããï¼ãã¨æã£ããã¢ã³ããã¿ã¼ã³ã ã£ããã¿ãããªãã¨ãããããã¾ããã
åããã¼ããç¥èãéããæ¥ã
éçãæããåã¯ãããã§ãã£ã¨ãã¡ããã¨ä½ç³»çã«å¦ç¿ããããã¨ããæ°ã«ãªãã¾ããã
OAuthãOpenID Connectã«ã¤ãã¦åå¦è
ã§ãããããããæè¡å人èªã夿°åºçããã¦ããAuthå±ãã(@authyasan)
- é°å²æ°ã§OAuth2.0ã使ã£ã¦ããã¨ã³ã¸ãã¢ãOAuth2.0ãæ´çãã¦ãæãåãããªããå¦ã¹ãæ¬
- Authå± Authå± OAuthãOAuthèªè¨¼ãOpenID Connectã®éããæ´çãã¦çè§£ã§ããæ¬
- OAuthã»OIDCã¸ã®æ»æã¨å¯¾çãæ´çãã¦çè§£ã§ããæ¬ï¼ãªãã¤ã¬ã¯ãã¸ã®æ»æç·¨ï¼
ãèªã¿ããã®å¾
- The OAuth 2.0 Authorization Framework - RFC 6749
- OAuth 2.0 Bearer Token Usage - RFC 6750
- Proof Key for Code Exchange by OAuth Public Clients - RFC 7636
- JSON Web Encryption (JWE) - RFC 7516
- JSON Web Key (JWK) - RFC 7517
çã
ãèªãã§ãå°ããã¤ç¥èãèãã¦ãã¾ããï¼ãã¡ããä»ããã®éä¸ã§ãï¼ã
ãããã¦ããç¨åº¦ç¥èãã¤ãã¦ããã¨ããããã¯æ©ãã«èªãã§ããã¹ãã ãªãã¨ãããããã¯å¿
è¦ã«ãªãã°èªãã°ãããã¤ã ãªãã¨ãã£ã¦ããã®ãä½ã¨ãªãè¦ãã¦ãã¾ããæ¬¡ç« ã§ã¯ãã®è¾ºãã®åæãèªè
ã®çããã«ä¼ãããã¨æã£ã¦ãã¾ãã
åå¿è ã®åã¸
ãã¦ããã£ã¨æ¬é¡ã§ããå¿ããæ¹ã¯ããã ãèªãã§ããããã°å¤§ä¸å¤«ã§ãã
ã¾ãã¯ããã°ãªã©ã§ OAuth ãæ¦è¦³ãã¹ã
ãããªã仿§ãèªãã®ã¯æ®éã¯å³ããã¨æãã®ã§ãã¾ãã¯ããã°çã§æ¦è¦ãç¥ãã¨è¯ãã¨æãã¾ãã人ã«ãã£ã¦ã¯ãããªãæ¸ç±ã«å
¥ãæ¹ãããããã人ãããããããã¾ããããåºæ¬çã«ææ°ã®ä»æ§çã¯ã¤ã³ã¿ã¼ãããä¸ã§è°è«ããããããã¤ã³ã¿ã¼ãããã§æ
å ±åéããã³ããæ´ãã§ããã¨å½¹ã«ç«ã¤ããããã¾ããã
ã¡ãªã¿ã«ãããã®æ
å ±ã¯ãã¾ã«å°ãçå½ã®æªããå
容ã®ãã®ããã£ããããã®ã§ãããã¯æ³¨æãå¿
è¦ã§ãã
ããã°ã«é¢ãã¦ã¯ããããã®è¨äºãèªã¿ã¾ããããç¹ã«ä»¥ä¸ã®æ¹ã
ã®è¨äºãããæè¦ãã¦ãã¾ããï¼ãã¤ããä¸è©±ã«ãªã£ã¦ããã¾ãï¼ã
- ãããã¬ã¹ãª OAuth/OIDC ã¨ã³ã¸ã³ãæä¾ãããµã¼ãã¹ãéå¶ããã¦ãã Authlete ããã®è¨äºï¼CEO å·å´ããã®å人è¨äºãå«ãï¼
- OpenID Foundation Japan ã§ãæ´»èºããã¦ãã ritou ããã®è¨äº
- OpenID Foundation ã®çäºé·ãåãããã¦ãã Nat Sakimura ããã®è¨äº
OAuth ã«é¢ããæ¸ç±ãèªãã¹ã
ããã°è¨äºã ãã§ã¯çè§£ããããªãç¥èãå¿
ãããã¯ããªã®ã§ãæ¸ç±ã使ã£ã¦è£å®ãã¾ãããï¼åè¿°ã®éãã好ã¿ã«ãã£ã¦ã¯ãããªãæ¸ç±ã§ãè¯ãã¨æãã¾ãï¼åã®å人çãªãå§ãã¯ãAuthå±ãããã®ãé°å²æ°OAuthæ¬ãã§ãã
æ¸ç±ãèªããã¨ã§ OAuth ã®å
¨ä½åãããªãã¯ãªã¢ã«è¦ãã¦ããã¨æãã¾ããå人çã«ã¯ RFC6749 ãããã®ä»ã® OAuth é¢é£ä»æ§ãç´æ¥åç
§ããã®ã¯ãã®å¾ãããã¨èãã¦ãã¾ãããã¡ãããããªã仿§ãèªãã§çè§£ã§ãã人ãããã¨ã¯æãã¾ããããæè¡çã«çè§£ã§ãããã¨ãã¨ããªããã®ä»æ§ãããã®ãã¨ããæ¬è³ªé¨åãçè§£ãããã¨ãã®éã«å¤§ããªéããããããåã¯ä»æ§ãé çªã«èªãã ãã§ã¯ããªããã®ä»æ§ãããã®ãã¨ããæ¬è³ªé¨åãçè§£ããããã¨ã¯ããªãé£ããã¨èãã¦ãã¾ãã
æºãæãã¦ä»æ§ãèªãã¹ã
ããã¾ã§ãã㨠OAuth ã®æãç«ã¡ãä»çµã¿ãããªãã®è§£å度ã§çè§£ã§ãã¦ããã¨æãã¾ããã¤ãã«ä»æ§ã®æµ·ã«é£ã³è¾¼ãæãæ¥ã¾ããã
ã¾ã㯠https://oauth.net/2/ ãè¦ã¦ã¿ã¾ãããã OAuth 2.0 ã®å¨ãã«ã¯ããããã®ä»æ§ãããã¾ãããã¡ããä¸ããé çªã«å
¨é¨èªãã§ãããã§ããããããã«å¤§å¤ãªã®ã§ï¼åã¯ã¾ã ååãç®ãéãã¦ããªãã§ãï¼å人çã«ã¯ã¾ã㯠Proof Key for Code Exchange by OAuth Public Clients ãèªããã¨ããããããã¾ãã Proof Key for Code Exchange (PKCE) ã¨ããä»çµã¿ã¯ã
- HTTP ã¨ããã¹ãã¼ãã¬ã¹ãªãããã³ã«ã®ä¸ã§ã©ã®ããã«ãèªå¯ãªã¯ã¨ã¹ããéã£ã人ãã¨ããã¼ã¯ã³ãªã¯ã¨ã¹ããéã£ã人ããåä¸ã§ãããã¨ãæ ä¿ããã
ã¨ããã OAuth ãé·ãã«æ¸¡ã£ã¦æ¦ã£ã¦ããåé¡ã¸ã®æ ¹æ¬çãªã¢ããã¼ãã¨ãã¦åå¨ããã¨èãã¦ãã¾ããå ç¢ãªããã¼ãæ§ç¯ããããã«ã¯å¿ è¦ä¸å¯æ¬ ãªè¦ç´ ãªã®ã§ãä¸èªãã価å¤ã¯ããã¯ãã§ãããã£ã¨å ·ä½çãªææ³ãå®è£ æ¹æ³ä»¥ä¸ã«å¾ããããã®ãããã§ãããã
ã¾ãã以ä¸ã®ããããèªãã§ã¿ãã®ãé¢ç½ãããããã¾ããã
- Demonstration of Proof of Possession (DPoP)Â - RFC 9449
- Mutual TLSÂ - RFC 8705
ãããã¯æ¬è³ªçã«ã¯
- ã©ã®ããã«ããã¼ã¯ã³ãåãåã£ã人ãã¨ããã¼ã¯ã³ã使ã£ã人ããåä¸ã§ãããã¨ãæ ä¿ããã
ã¨ããåé¡ã«ã¢ããã¼ããããã®ã ã¨èãã¦ãã¾ãã
ãã®ããã« OAuth ã«é¢ããåºç¤çãªçè§£ãããç¶æ
ã§ä»æ§ãèªããã¨ã§ãããããã®ä»æ§ã解決ãããã¨ãã¦ããæ¬è³ªçãªèª²é¡ããèªç¶ã¨çè§£ã§ããããã«ãªã£ã¦ãã¾ããããããªãã¨ä»æ§ãèªãã®ã楽ãããªã£ã¦ãã¾ãã
ã¾ããä¸åº¦ OAuth ã«å¯¾ãã¦ãã£ããåãåã£ããã¨ã§ãããèªãã 仿§ãããåãããªãå ´åã§ã次ã«ä½ãããã°è¯ããããèªç¶ã¨è¦ãã¦ãã¾ãï¼åãããªãã£ãæç®ãåããããã«ãªã£ãçµé¨ã£ã¦èªä¿¡ã«ãªãã¾ãããï¼ããã®ç¶æ
ã¾ã§ããããã°ããå¾ã¯ã©ãã«ã§ããªãã¾ãããããæå³ãããä¸ã¤ã®ã´ã¼ã«ã ã¨èãã¦ãã¾ãã
ä½ã«ã§ãè¨ãããã¨ããããã¾ããããèªè¨¼èªå¯ãå¦ç¿ããã¨ãã«ãããã仿§ãå
¨ã¦ææ¡ãã¦ããå¿
è¦ã¯ãªãã¨æã£ã¦ãã¾ããå¿
è¦ãªã®ã¯ä»æ§ãèªãã³ãã¨èªä¿¡ã§ãå
·ä½çãªä»æ§ã®å¤ãã¯å¿
è¦ãªã¨ãã«é½åº¦åç
§ããã°ååäºè¶³ããã¨ããã®ãæè«ã§ããã¡ãªã¿ã«ããã¾ã§ãã£ã¨ OAuth ã®è©±ããã¦ãã¾ãããããã®æç¹ã§ OpenID Connect Core 1.0 ããããªãèªããããã«ãªã£ã¦ããã¨æãã¾ããã OIDC ã«éãã OAuth ããã¼ã¹ã«ãªã£ã¦ãã仿§ã¯æ¦ãèªããããã«ãªã£ã¦ããã¯ãã§ãã
æ´ã㦠OIDC ããä¸å¿ç¥ã£ã¦ã¾ãããªäººã«ãªããã¨ãã§ãã¾ãããããã©ããªä»æ§ã§ãããã£ã¦ããã¨ããæ°æã¡ã«ãªã£ã¦ãã¾ãããï¼ããã§ãã仿§ã®æµ·ã®èªæµ·è¡ãæã«ããæã ã«æ»è§ã¯ããã¾ããããã®ã¾ã¾ OAuth ãæ·±æã£ã¦ãè¯ãã§ãããæè¿è©±é¡ã®ãã¹ãã¼ãMCPã®èªå¯ã«é¢ãã¦èª¿ã¹ã¦ã¿ã¦ãé¢ç½ããã§ããèå³é¢å¿ã®èµ´ãã¾ã¾ã«å¥½ããªä»æ§ãå¦ç¿ãã¦ããã¾ãããã
æå¾ã«
ä¸éãæ¸ããå¾ã«èªã¿è¿ãã¦ã¿ãã¨ãããæ³å®ãã¦ãããå½ããåã®ãã¨ãæ¸ãã¦ããªã¨æã£ã¦ãã¾ãã¾ãããå½ããåã®ãã¨ãå½ããåã«ããã£ã¦é£ããã§ãããï¼ï¼ï¼ã
ã¨ããã§ãããªããã°ãæ¸ãã¦ã¾ãããå®éã®ã¨ãããç§ãéã£ãéãã§ç´¹ä»ããããæ¹ãããã»ã©æªãã£ãã¨ã¯æã£ã¦ãã¾ããããã ã人éã£ã¦äºå¨ç®ã¯ä¸æãããããã£ã¦ã©ããã¦ãæã£ã¦ãã¾ãã¾ããããæ¬å½ã¯ä¸å¨ç®ã«çµé¨ããåãéã®ä¸ã«å¤§äºãªä½ãããã£ãããããã¾ããããããã¯åã«ã¯ããåããã¾ããã
åããã®è¨äºã§æ¬å½ã«ä¼ãããã£ããã¨ã¯ããè¨ã£ã¡ãã£ãããä½ã¨ãããªãã¨â¦ãã¿ãããªéªãªçç±ã§ã¹ã¿ã¼ããã¦ããæå¾ã«ã¯ä½ã¨ããªãã£ã¦ãã¨ã§ãã OAuth/OIDC ã£ã¦å
容ãçè§£ããã ããªãã¶ã£ã¡ãããããªã«é£ãããªãã®ã§ãããæ°ãããã°ã©ãã«ã§ããªãã¨æãã¾ããããããæ°ããã人ããããããã®è¨äºãã¡ãã£ã¨ã ãåèã«ãã¦ã¿ã¦ããããã¨å¬ããã§ããããã¦ãã¤ãç¡é§ã«äºå¨ç®ã«æãã馳ããããã¦ã¿ã¾ãããã
ãã®è¨äºãæ¸ãã¦ãã¦ãµã¨ãæè¿ãã¾ã仿§ãèªãã§ãªããªã¼ãã¨æãã¾ããããã£ã¨ããããã®ä»æ§ãèªãããããããä¸å±¤ç²¾é²ããæ°æã¡ã§æº¢ãã¦ãã¾ãããããªåã¨ä¸ç·ã«ç²¾é²ãã¦ããã仲éãã«ããã·ã®èªè¨¼èªå¯ã¦ãããã§ã¯åéãã¦ãã¾ãï¼
æå¾ã¾ã§ãèªã¿ããã ããããã¨ããããã¾ããï¼