æçš¿è ïŒVyacheslav Mikhailovããœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ã
ããã¯ãæšå¹Žã®å€ã«èªãã ã¬ããŒãã«åºã¥ããå ¥éæžã§ãã å°å·ç©ã¯ã次ã®ãããªè©³çŽ°æ å ±ãææ¡ããŸã 1ã€ã®ã¬ããŒãã§ã¯ãéåžžããã¹ãŠã®è©³çŽ°ã«ã€ããŠè©±ãããšã¯ã§ããŸããã
ãŠãŒã¶ãŒèªèšŒããã»ã¹ãã·ã³ã°ã«ãµã€ã³ãªã³/ SSOãã¯ãããžãŒã®æäœãæ±ããç¹å®ã®æè¡çãªå®è£ ãæãäžããããšãªããOAuth2ãã¯ãããžãŒãšãã®ä»çµã¿ã®æŠèŠã説æããŸãã 次ã®èšäºã§ã¯ãå®è£ ã®æåäŸãšããŠãThinktecture Identity Server v3ã©ã€ãã©ãªãŒã«ã€ããŠæ€èšãããã®æ©èœã«ã€ããŠè©³ãã説æãããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã§ã®äœæ¥ã«å¿ èŠã§ãããæŠéã·ã¹ãã ã§ã®äœ¿çšã«ãµããããã³ã³ããŒãã³ãã®æå°ã»ãããçµã¿ç«ãŠãæ¹æ³ã«ã€ããŠèª¬æããŸãã 第3éšã§ã¯ãã·ã¹ãã ã®ããŒãºã«åãããŠãã®ã©ã€ãã©ãªãæ¡åŒµããå€ãã®éçºè ã®äººçã§ééããããŸããŸãªã·ããªãªãåã±ãŒã¹ã®æšå¥šäºé ãšãšãã«åæããããšã«ãããäžé£ã®èšäºãå®æãããæ¹æ³ã瀺ããŸãã
èªèšŒãšã¯äœã§ããïŒ
èªèšŒãšæ¿èªã®ããã»ã¹ã¯ãã¢ã¯ã»ã¹æš©ã®åé¢ã«åºã¥ããŠããããããªãã§ã¯å€ããå°ãªããæ·±å»ãªã¢ããªã±ãŒã·ã§ã³ã¯å®è¡ã§ããŸããã ãããã£ãŠããããã以åã©ã®ããã«çºçããçŸåšã©ã®ããã«çºçããŠããããç解ããããšã¯éåžžã«éèŠã§ããããã¯ãããžãŒã®èª¬æãæãäžããåã«ãéèŠãªçšèªãèŠãŠã¿ãŸãããã
èå¥ãšã¯ãç®ã®åã«ã©ããªäººãããããå€æããããã»ã¹ã§ãã èªèšŒã¯ããã®äººç©ãæ¬äººã§ããããšãæ£ç¢ºã«ç¢ºèªããããã»ã¹ã§ãã èªå¯ãšã¯ããã®èªèšŒããã人ç©ã«äœãèš±å¯ãããã決å®ããããã»ã¹ã§ãã ã€ãŸãããããã¯3ã€ã®ç°ãªãäžè²«ããæŠå¿µã§ãããçžäºã«äº€æã§ããªãæŠå¿µã§ãã å€ãã®å ŽåãèªèšŒã®äžéšãšããŠèå¥ãæ瀺ãããŸãã æãéèŠãªããšã¯ãèªèšŒãšæ¿èªãæ確ã«åºå¥ããããšã§ãã
èªèšŒäžã«ãç§ãã¡ã«æ¥ã人ã身å ã®èšŒæ ãæã£ãŠããããšã確èªããŸãã ãã®èšäºã§ã¯äž»ã«èªèšŒã«çŠç¹ãåœãŠãŸãã
èªèšŒæ¹æ³
HTTPãããã³ã«ã䜿çšããå ŽåãæãåçŽãªèªèšŒæ¹æ³ã¯åºæ¬ã¢ã¯ã»ã¹èªèšŒã§ãã ååãšããŠããã®ãããã³ã«ã¯æ代é ãã§ãããç¹ã«ä¿è·ãããŠããªãæ¥ç¶ã§ã€ã³ã¿ãŒãããã§äœ¿çšãããããšã¯ã»ãšãã©ãããŸãããããããã®äžéšããã£ãšåã«äœæããããšããçç±ã ãã§äŒæ¥ã·ã¹ãã ã«ä¿åãããŸãã ä»çµã¿ãç解ãã䟡å€ããããŸãã
HTTPåºæ¬èªèšŒ
ä¿è·ããããªãœãŒã¹ã«ã¢ã¯ã»ã¹ãããšããµãŒããŒã¯ã¢ã¯ã»ã¹æš©ã®ãªããŠãŒã¶ãŒãçºè¡ãããšããæåã®åé¡ã¯ã401 Unauthorizedãšã©ãŒã«ãªããŸãã å¿çã«ã¯ãåãå ¥ããããšãã§ããèªèšŒã®çš®é¡ïŒãã®å Žåã¯BasicïŒãããã³ãã®èªèšŒãæå¹ãªã³ã³ããã¹ãïŒé åïŒã«é¢ããæ å ±ãå«ãŸããŠããŸãã ãŠãŒã¶ãŒããŠãŒã¶ãŒåãšãã¹ã¯ãŒããå ¥åãããšããããã¯Base64ã«ããã±ãŒãžåãããæ€èšŒã®ããã«ãµãŒããŒã«éä¿¡ãããŸãã ããã«ã¯ããŸããŸãªå±éºããããŸãã æãäžè¬çãªã®ã¯ãäžéè æ»æãŸãã¯äžéæ»æã®è åšã§ãããã®éãå®å šã§ãªãæ¥ç¶ã䜿çšããŠãæ»æè ã¯ã¯ã©ã€ã¢ã³ããããµãŒããŒãžããŸãã¯ãµãŒããŒãžã®è»¢éæã«è³æ Œæ å ±ãååã§ããŸãã
HTTPãã€ãžã§ã¹ãèªèšŒ
æè¡éçºã®æ¬¡ã®ã¹ãããã¯ããããã«è€éãªHTTPãã€ãžã§ã¹ãèªèšŒã·ã¹ãã ã§ãããããã«ãããæ確ãªè³æ Œæ å ±ãäžèŠã«ãªããŸããããã§ã¯ãæ€èšŒã«ããã€ãã®äžçŽç©ãå«ãMD5ããã·ã¥ã䜿çšããããã°ã€ã³ãšãã¹ã¯ãŒãã®éžæãåé¿ãããŸãã ãã¡ããããã®ã¢ã«ãŽãªãºã ã¯ããä¿¡é Œæ§ãé«ãããã«èŠããŸãããããã»ã©è€éã§ã¯ãªãæ»æãå€ãçºçããŸãã ããšãã°ã ããã§ã¯æ»æã«ã€ããŠããã«è©³ããèªãããšãã§ããŸãã
ãã©ãŒã èªèšŒ
ãã®åŸããã©ãŒã èªèšŒããã»ã¹ãç»å ŽããŸããããã®ããã»ã¹ã§ã¯ãæœè±¡åã¢ãã«ã®ããé«ãã¬ãã«ã§èªèšŒãè¡ãããŸãã HTTPãµãŒããŒã¯ã¢ã¯ã»ã¹ãšã©ãŒãå ±åãããèªèšŒãããŠããªããŠãŒã¶ãŒãå¥ã®ããŒãžã«ãªãã€ã¬ã¯ãããã ãã§ãã éåžžããã®ããŒãžã«ã¯ãã°ã€ã³ãšãã¹ã¯ãŒããå ¥åããããã®ãã£ãŒã«ãã衚瀺ãããŸããå ¥ååŸã POSTèŠæ±ãããŒã¿ã§çæãããå®å šãªãã£ãã«ãéããŠãµãŒããŒã«éä¿¡ãããŸãã ãµãŒããŒåŽã¯ããŠãŒã¶ãŒã«ããŒã¯ã³ãŸãã¯ã»ãã·ã§ã³èå¥åãè¿ããŸããããŒã¯ã³ãŸãã¯ã»ãã·ã§ã³èå¥åã¯ãCookieã«ä¿åãããä¿è·ããããªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ã«äœ¿çšãããŸãã
ããŒã¯ã³èªèšŒ
次äžä»£ã®èªèšŒæ¹æ³ã¯ãããŒã¯ã³ããŒã¹ã®èªèšŒã§ããããã¯ãã·ã³ã°ã«ãµã€ã³ãªã³ïŒSSOïŒã·ã¹ãã ã®æ§ç¯ã§äžè¬çã«äœ¿çšãããŸãã 䜿çšããå ŽåãèŠæ±ããããµãŒãã¹ã¯ããŠãŒã¶ãŒæ å ±ãæ€èšŒããæ©èœãå¥ã®ãµãŒãã¹ã«å§ä»»ããŸãã ã€ãŸãããµãŒãã¹ãããã€ããŒã¯ãããŒã¯ã³ãããã€ããŒèªäœïŒIDãããã€ããŒïŒãžã®ã¢ã¯ã»ã¹ã«å¿ èŠãªããŒã¯ã³ã®çºè¡ãä¿¡é ŒããŸãã ããã¯ãããšãã°ããœãŒã·ã£ã«ãããã¯ãŒã¯ã®ã¢ã«ãŠã³ããä»ããŠã¢ããªã±ãŒã·ã§ã³ãå ¥åããå Žåã«èŠããããã®ã§ãã IT以å€ã§ã¯ããã®ããã»ã¹ã®æãåçŽãªäŸãã¯ãå ±éã®ãã¹ããŒãã®äœ¿çšã§ãã å ¬åŒææžã¯ããªãã«çºè¡ãããåãªãããŒã¯ã³ã§ã-ãã¹ãŠã®å ¬å ±ãµãŒãã¹ã¯ãããã©ã«ãã§ããããæž¡ããèŠå¯çœ²ãä¿¡é Œãããã®å®å šæ§ãç¶æããªãããæå¹æéãéããŠèªèšŒã«ãã¹ããŒããååãšèŠãªããŸãã
ãã®å³ã¯ãããŒã¯ã³èªèšŒã䜿çšããå Žåã«ã¢ããªã±ãŒã·ã§ã³ãæ å ±ã亀æããæ¹æ³ãšé åºãæ確ã«ç€ºããŠããŸãã
次ã®å³ã¯ããŠãŒã¶ãŒãçŽæ¥é¢äžããçžäºäœçšã®æ®µéãããã«åæ ããŠããŸãã ãã®ç¹ã¯ããã®ãããªã¹ããŒã ã®æ¬ ç¹ã§ãããªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãååŸããã«ã¯ãåžžã«ãŠãŒã¶ãŒãå¿ èŠã§ãã
OAuth2ãšOpen ID Connect
èªèšŒããŒã¯ã³ã¯ä¿è·ããããªãœãŒã¹ã«ã¢ã¯ã»ã¹ããç¬éã«ãŠãŒã¶ãŒã®ååšãå¿ èŠãšãããããããã»ã¹ã®ãããªãæ¹åãå¿ èŠã§ããã ãªããªããIDãããã€ããŒã¯ãã³ã³ãããŒã«ãå¶åŸ¡ã«è»¢éãããšãã«ããŠãŒã¶ãŒãšå¯Ÿè©±ããŠãããšãã°ãã°ã€ã³ãšãã¹ã¯ãŒããèŠæ±ããããã§ãã
ããšãã°ããœãŒã·ã£ã«ãããã¯ãŒã¯ã®é£çµ¡å ãªã¹ãã«ã¢ã¯ã»ã¹ããããã«ããŠãŒã¶ãŒã«ä»£ãã£ãŠäžå®ã®ééã§ç¹å®ã®3çªç®ã®ãªãœãŒã¹ã«åãåãããå¿ èŠããããµãŒãã¹ã®å ŽåãããŒã¯ã³èªèšŒã¯æ©èœããªããªããŸãã å®éã«ã¯ãã»ãã·ã§ã³èå¥åã¯éåžžéåžžã«é·ãã¯çããªããããååãããå Žåãæ»æè ã¯éãããæéã ããµãŒãã¹ã«ã¢ã¯ã»ã¹ã§ããŸãã ãã ããæå¹æéãçããããããšãã°å€éã®ããã»ã¹ã§ã¯ããŒã¯ã³ã¯ååã§ã¯ãããŸããã
2006幎ãTwitterã®Open IDãããã³ã«ã®å®è£ ã«åãââçµãã§ããéã«ãæ°ãããªãŒãã³èªèšŒãããã³ã«ã®å¿ èŠæ§ãæµ®äžããŸããã 2007幎ã«GoogleãšAOLã®ãšã³ãžãã¢ãååãå§ãã2009幎ã«Twitterã¯ãŠãŒã¶ãŒã«ãOAuthãããã³ã«ã«åºã¥ããŠãµãŒãããŒãã£ãµãŒãã¹ãžã®ã¢ã«ãŠã³ããžã®ã¢ã¯ã»ã¹ãå§ä»»ãããœãªã¥ãŒã·ã§ã³ãæäŸããŸããã 3幎åŸãæ°ããããŒãžã§ã³-OAuth 2ãå ¬éãããŸãããããã«ãããã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã®éçºãç°¡çŽ åããããŠãŒã¶ãŒã®ä»å ¥ãªãã§ããŒã¯ã³ãæŽæ°ãããªã©ãå€ãã®æ°æ©èœãæäŸãããŸããã å€ãã®ãµãŒãã¹ã¯ãå ¬åŒã«æ¿èªãããåã«ãã®ãããã³ã«ã®äœ¿çšãéå§ããŸããã
xyããxyã詳现ã«ç解ããŸã
çŸåšã次ã®ãããã³ã«ã審çäžã§ãã
- OpenID-ãŠãŒã¶ãŒè³æ Œæ å ±ïŒèå¥ãšèªèšŒïŒãæ€èšŒããŸãã
- OAuthãšã¯ãäœãã«ã¢ã¯ã»ã¹ããããšã§ãã
- OpenID Connect-äž¡æ¹ã«ã€ããŠã
3ã€ã®ãããã³ã«ã¯ãã¹ãŠããŠãŒã¶ãŒãèªåã®ç§å¯ã®ãŠãŒã¶ãŒåãšãã¹ã¯ãŒããä¿¡é Œã§ããªãã¢ããªã±ãŒã·ã§ã³ã«é瀺ããªãããã«ããŸãã OpenIDãšOAuthã¯2014幎ãŸã§äžŠè¡ããŠéçºãããæçµçã«OpenID Connectã«çµ±åãããŸããã
OpenID 1.0 ïŒ2006ïŒããã³OpenID 2.0 ïŒ2007ïŒã§ã¯ãã¢ããªã±ãŒã·ã§ã³ïŒarbïŒãä¿¡é Œã§ãããµãŒããŒïŒæš©éïŒããã®ãŠãŒã¶ãŒãã§ãã¯ãèŠæ±ã§ããŸããã ããŒãžã§ã³éã®éãã¯éèŠã§ã¯ãããŸããã
- ãŠãŒã¶ãŒ->ã¢ããªïŒããã«ã¡ã¯ãMishaã§ãã
- ã¢ããª->æš©éïŒããã¯ããã®ãããŒã·ã£ã§ããïŒ
- æš©éãšãŠãŒã¶ãŒã¯å¯Ÿé¢ã§éä¿¡ããŸãã
- Authority-> AppïŒã¯ããããã¯Mishaã§ãã
OpenID Attribute Exchange 1.0 ïŒ2007ïŒã¯ããŠãŒã¶ãŒãããã¡ã€ã«ãååŸããã³ä¿åã§ããããã«ããããšã§OpenID 2.0ãæ¡åŒµããŸãã
- ãŠãŒã¶ãŒ->ã¢ããªïŒããã«ã¡ã¯ãMishaã§ãã
- ã¢ããª->æš©éïŒããã¯ããã®ãããŒã·ã£ã§ããïŒ ãããããŒã·ã£ã®å Žåã圌ã«ã¡ãŒã«ãéã£ãŠãã ããã
- æš©éãšãŠãŒã¶ãŒã¯å¯Ÿé¢ã§éä¿¡ããŸãã
- Authority-> AppïŒã¯ããããã¯Mishaã§ãã ãããŠåœŒã®ã¡ãŒã«ã¯xxx@xxx.xxxã§ãã
OAuth 1.0 ïŒ2010ïŒã䜿çšãããšããŠãŒã¶ãŒã¯ãèªèšŒæ©é¢ãä¿¡é ŒãããµãŒãããŒãã£ãµãŒããŒïŒãµãŒãããŒãã£ãµãŒããŒïŒã§ã¢ããªã±ãŒã·ã§ã³ã«å¶éä»ãã¢ã¯ã»ã¹ãèš±å¯ã§ããŸãã
- ã¢ããª->ãŠãŒã¶ãŒïŒå¥ã®ãµãŒããŒããåçãåãåãããã
- æš©éãšãŠãŒã¶ãŒã¯å¯Ÿé¢ã§éä¿¡ããŸãã
- æ©é¢->ã¢ããªïŒããã«ã¯15åéã®ãã±ããïŒã¢ã¯ã»ã¹ããŒã¯ã³ïŒããããŸãã
- ã¢ããª->ãµãŒãããŒãã£ãµãŒããŒïŒããã§ã¯ããã±ããã§ãã®ãŠãŒã¶ãŒã®åçãååŸã§ããŸãã
OAuth 2.0 ïŒ2012ïŒã¯OAuth 1.0ãšåãã§ããããããã³ã«ã®ã¿ãå€§å¹ ã«å€æŽãããããã·ã³ãã«ã«ãªããŸããã
OpenID Connect ïŒ2014ïŒã¯ãOpenID 2.0ãOpenID Attribute Exchange 1.0ãããã³OAuth 2.0ã®æ©èœã1ã€ã®å ±éãããã³ã«ã«çµåããŸãã ã¢ããªã±ãŒã·ã§ã³ã¯ãèªèšŒæ©é¢ã䜿çšããŠæ¬¡ã®ããšãã§ããŸãã
- ãŠãŒã¶ãŒè³æ Œæ å ±ã確èªããŠãã ããã
- ãŠãŒã¶ãŒãããã¡ã€ã«ïŒãŸãã¯ãã®äžéšïŒãåãåããŸãã
OpenID Connectã¯å€éšãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãæäŸããªãããšãç解ããããšãéèŠã§ãã OAuth 2.0ã䜿çšããŠããããã¡ã€ã«ãã©ã¡ãŒã¿ããã®ãããªãªãœãŒã¹ã§ãããã®ããã«æ瀺ããŸãã
å¹³é¢å³
éåžžãã·ã¹ãã ã«ã¯ããŸããŸãªã³ã³ããŒãã³ãããããŸãããã©ãŠã¶ãä»ããŠäœæ¥ãããŠãŒã¶ãŒãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãä»ããŠãµãŒããŒãšå¯Ÿè©±ãããŠãŒã¶ãŒãããã³Web APIãä»ããŠã¢ã¯ã»ã¹ãããä»ã®ãµãŒããŒã«ä¿åãããããŒã¿ãå¿ èŠãšãããµãŒããŒã¢ããªã±ãŒã·ã§ã³ã®ã¿ã§ãã
ã·ã³ã°ã«ãµã€ã³ãªã³-ã·ã³ã°ã«ãµã€ã³ãªã³ãã¯ãããžãŒ-ãŠãŒã¶ãŒã¯ãåèªèšŒãªãã§ç°ãªãã¢ããªã±ãŒã·ã§ã³ãåãæ¿ããããšãã§ããŸãã SSOã䜿çšãããšãè€æ°ã®ãã°ã€ã³ãåé¿ã§ããããããŠãŒã¶ãŒã¯ãããã®ã¹ã€ããã«æ°ä»ããªãã ãã§ãã ãã®å Žåãã€ã³ãã©ã¹ãã©ã¯ãã£å ã«ãã®ãããªã¢ããªã±ãŒã·ã§ã³ãè€æ°ååšããç¶æ³ã¯åžžã«æºããããŠããŸãã ã·ã³ã°ã«ãµã€ã³ãªã³ãã¯ãããžã¯ãççµåãããå€æ°ã®ã¢ããªã±ãŒã·ã§ã³ã§æ§æããã倧èŠæš¡ãªãšã³ã¿ãŒãã©ã€ãºã·ã¹ãã ã§ç¹ã«äŸ¿å©ã§ãã ãŠãŒã¶ãŒãã¿ã€ã ãã©ããã³ã°ã·ã¹ãã ãäŒæ¥ãã©ãŒã©ã ããŸãã¯ããã¥ã¡ã³ãã®å éšããŒã¿ããŒã¹ã«ã¢ã¯ã»ã¹ãããã³ã«ãŠãŒã¶ãŒåãšãã¹ã¯ãŒããå ¥åããŠãæºè¶³ãããããšã¯ã»ãšãã©ãããŸããã
å®è£ ãšããŠãOAuth2ãããã³ã«ãæ€èšããŸãã ååãšããŠãWindowsãšæ£åžžã«ããåãããKerberosãªã©ã®ä»ã®ãã®ããããŸãããWindowsãMacãããã³UNIXã·ã¹ãã ã®äž¡æ¹ã䜿çšããã³ã³ãã¥ãŒã¿ãŒãããç°çš®ãããã¯ãŒã¯ã®å Žåãç¬èªã®ãããã³ã«ã䜿çšããããšã¯ãã°ãã°äžäŸ¿ã§ãã ããã«ãããã¯ãµãŒãã¹ãžã®ã¢ã¯ã»ã¹ãWebçµç±ã§å®è¡ãããå Žåã«é©çšãããŸã-ããã§ã¯OAuth2ãæé©ãªåè£ã§ãã
äžã®å³ã¯ãåã¿ã€ãã®å¯Ÿè©±ã«äœ¿çšããããããã³ã«ã瀺ããŠããŸãã
ã xyããxyã詳现ã«ç解ããŠãã ãã»ã¯ã·ã§ã³ãããããããã«ããŠãŒã¶ãŒãããŠãŒã¶ãŒè³æ Œæ
å ±ãååŸããŠç¢ºèªããã«ã¯ãOpenID Connectãå¿
èŠã§ãã OAuth 2.0ã¯ãã¢ã¯ã»ã¹ããŒã¯ã³ãåãåãããããã«ã¢ã¯ã»ã¹ããããã«å¿
èŠã§ãã
OAuth2ããã³OpenID Connectã®çšèª
- OpenID Connectãããã€ããŒïŒOPïŒ
- ã¯ã©ã€ã¢ã³ã
- ãŠãŒã¶ãŒ
- ç¯å²
- IDã¹ã³ãŒã-OpenIDããããã¡ã€ã«ãã¡ãŒã«
- ãªãœãŒã¹ã¹ã³ãŒã-ããŸããŸãªAPI
- èªèšŒ/ããŒã¯ã³ãªã¯ãšã¹ã
- èå¥ããŒã¯ã³
- ã¢ã¯ã»ã¹ããŒã¯ã³
- æŽæ°ããŒã¯ã³
ããŒã¯ã³çºè¡ãµãŒãã¹
Open ID Connectãããã€ããŒã¯ãäžå€®éäžåèªèšŒãµãŒãã¹ã®èšèšå šäœã§æãéèŠãªãªããžã§ã¯ãã§ããã»ãã¥ãªãã£ããŒã¯ã³ãµãŒãã¹ãIDãããã€ããŒèªèšŒãµãŒããŒãªã©ãšãåŒã°ããŸããããŸããŸãªãœãŒã¹ãç°ãªãæ¹æ³ã§åŒã³åºããŸãããã¯ã©ã€ã¢ã³ãã«ããŒã¯ã³ãçºè¡ãããµãŒãã¹ã§ãã
äž»ãªæ©èœïŒ
- å éšãŠãŒã¶ãŒã¹ãã¬ãŒãžãŸãã¯å€éšãœãŒã¹ïŒActive Directoryãªã©ïŒã䜿çšããŠãŠãŒã¶ãŒãèªèšŒããŸãã
- ã¯ã©ã€ã¢ã³ãïŒã¹ãã¢ïŒã管çããèªèšŒããŸãã
- ã»ãã·ã§ã³ç®¡çãšã·ã³ã°ã«ãµã€ã³ãªã³ãå®è£ ããæ©èœãæäŸããŸãã
- IDããŒã¯ã³ãšã¢ã¯ã»ã¹ããŒã¯ã³ãã¯ã©ã€ã¢ã³ãã«çºè¡ããŸãã
- 以åã«çºè¡ãããããŒã¯ã³ã確èªããŠãã ããã
ã客æ§
ã¯ã©ã€ã¢ã³ã-ãŠãŒã¶ãŒèªèšŒçšã®ããŒã¯ã³ãŸãã¯ç¹å®ã®ãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹çšã®ããŒã¯ã³ã®ãããããå¿ èŠãšããããã€ã¹ãŸãã¯ããã°ã©ã ïŒãã©ãŠã¶ãŒãã¢ããªã±ãŒã·ã§ã³ïŒïŒãã®ãªãœãŒã¹ã¯ãã¯ã©ã€ã¢ã³ããããŒã¯ã³ãèŠæ±ããç¹å®ã®ã ã»ãã¥ãªãã£ããŒã¯ã³ãµãŒãã¹ ãã«ã銎æã¿ããããããšãç解ãããã¢ã¯ã»ã¹çšïŒã
ãŠãŒã¶ãŒ
ãŠãŒã¶ãŒ-å®éã«ã¯ãšã³ããŠãŒã¶ãŒã¯äººã§ãã
ç¯å²
ã¹ã³ãŒã-ã¯ã©ã€ã¢ã³ããã¢ã¯ã»ã¹ããããªãœãŒã¹ã®èå¥åã ã¹ã³ãŒããªã¹ãã¯ãèªèšŒèŠæ±ã®äžéšãšããŠããŒã¯ã³çºè¡ãµãŒãã¹ã«éä¿¡ãããŸã ã
ããã©ã«ãã§ã¯ããã¹ãŠã®ã¯ã©ã€ã¢ã³ãã¯ä»»æã®ãšãªã¢ãèŠæ±ããããšãã§ããŸãããããã¯ããŒã¯ã³çºè¡ãµãŒãã¹ã®æ§æã§å¶éããããšãã§ããŸãïŒããã³å¶éããå¿ èŠããããŸãïŒ ã
ã¹ã³ãŒãã«ã¯2ã€ã®åœ¢åŒããããŸãã
- IDã¹ã³ãŒãã¯ããŠãŒã¶ãŒæ å ±ã®èŠæ±ã§ãã 圌ã®ååããããã£ãŒã«ãæ§å¥ãåçãã¡ãŒã«ã¢ãã¬ã¹ãªã©
- ãªãœãŒã¹ã¹ã³ãŒãã¯ãã¯ã©ã€ã¢ã³ããã¢ã¯ã»ã¹ãããå€éšãªãœãŒã¹ïŒWeb APIïŒã®ååã§ãã
èªèšŒãªã¯ãšã¹ã
èªèšŒ/ããŒã¯ã³èŠæ±-èªèšŒèŠæ±ããã»ã¹ã
èŠæ±ãããã¹ã³ãŒãã«å¿ããŠãããŒã¯ã³çºè¡ãµãŒãã¹ã¯ä»¥äžãè¿ããŸãã
- IDã¹ã³ãŒãã®ã¿ãèŠæ±ãããå Žåã¯ãIDããŒã¯ã³ã®ã¿ã
- ãªãœãŒã¹ã¹ã³ãŒããèŠæ±ãããå Žåã¯ãIDããŒã¯ã³ãšã¢ã¯ã»ã¹ããŒã¯ã³ã
- ãªãã©ã€ã³ã¢ã¯ã»ã¹ãèŠæ±ãããå Žåãã¢ã¯ã»ã¹ããŒã¯ã³ãšãªãã¬ãã·ã¥ããŒã¯ã³ã
èªèšŒããã»ã¹ã®è©³çŽ°ã«ã€ããŠã¯ããèªèšŒããã»ã¹ ãã»ã¯ã·ã§ã³ãã芧ãã ããã
ããŒãœããªãã£ããŒã¯ã³
IDããŒã¯ã³-èªèšŒç¢ºèªã ãã®ããŒã¯ã³ã«ã¯ããŠãŒã¶ãŒæ å ±ã®æå°éã®ã»ãããå«ãŸããŠããŸãã
ã¢ã¯ã»ã¹ããŒã¯ã³
ã¢ã¯ã»ã¹ããŒã¯ã³-ç¹å®ã®ãŠãŒã¶ãŒã«èš±å¯ãããŠããæ å ±ã ã¯ã©ã€ã¢ã³ãã¯ã¢ã¯ã»ã¹ããŒã¯ã³ãèŠæ±ããããã䜿çšããŠãªãœãŒã¹ïŒWeb APIïŒã«ã¢ã¯ã»ã¹ããŸãã ã¢ã¯ã»ã¹ããŒã¯ã³ã«ã¯ãã¯ã©ã€ã¢ã³ããšãŠãŒã¶ãŒã«é¢ããæ å ±ãå«ãŸããŸãïŒååšããå ŽåïŒã ãŠãŒã¶ãŒãããã»ã¹ã«çŽæ¥é¢äžããŠããªããããªçš®é¡ã®æ¿èªãããããšãç解ããããšãéèŠã§ãïŒããã«ã€ããŠã¯æ¬¡ã®ããŒãã§è©³ãã説æããŸãïŒ
ããŒã¯ã³ãæŽæ°
æŽæ°ããŒã¯ã³-STSãæ°ããã¢ã¯ã»ã¹ããŒã¯ã³ãè¿ãããã®ããŒã¯ã³ã åäœã¢ãŒãã«å¿ããŠããªãã¬ãã·ã¥ããŒã¯ã³ã¯åå©çšå¯èœããã³äœ¿ãæšãŠå¯èœã§ãã ã¯ã³ã¿ã€ã ããŒã¯ã³ã®å Žåãæ°ããã¢ã¯ã»ã¹ããŒã¯ã³ãèŠæ±ãããšãæ¢è£œã®ãªãã¬ãã·ã¥ããŒã¯ã³ãçæãããŸããããã¯ãæŽæ°æã«äœ¿çšããå¿ èŠããããŸãã æããã«ãã¯ã³ã¿ã€ã ããŒã¯ã³ã¯ããå®å šã§ãã
ã»ã¯ã·ã§ã³ã ããŒã¯ã³æ§é ãã®ããŒã¯ã³ã®æ§æã«é¢ãã詳现ã
èªèšŒããã»ã¹
ãŠãŒã¶ãŒãã¯ã©ã€ã¢ã³ãã«ã¢ã¯ã»ã¹ãããšããŠãŒã¶ãŒã¯Open ID Connectãããã€ããŒã«ãªãã€ã¬ã¯ãããããŠãŒã¶ãŒã«ãŠãŒã¶ãŒåãšãã¹ã¯ãŒããèŠæ±ãããŸãã èªèšŒæ€èšŒãæåããå ŽåããŠãŒã¶ãŒãä¿è·ããããªãœãŒã¹ã«ã¢ã¯ã»ã¹ã§ããIDããŒã¯ã³ãšã¢ã¯ã»ã¹ããŒã¯ã³ãè¿ããŸãã
ããŒã¯ã³æ§é
æžåŒ
OAuth2å®è£ ã§ã¯ã3ã€ã®éšåã§æ§æãããããããjwtããŒã¯ã³ã䜿çšããŸãã IDãããã€ããŒã«é£çµ¡ãããšããã°ã€ã³/ãã¹ã¯ãŒããéä¿¡ãããã®ä»£ããã«ããŒã¯ã³ãåä¿¡ãããšããŸãã ããããŒïŒã¿ã€ãã«ïŒããã€ããŒãïŒã³ã³ãã³ãïŒãããã³çœ²åïŒçœ²åïŒãå«ãŸããŸãã jwt.ioã§ã¯ãããããã³ãŒãããJSON圢åŒã§ã³ã³ãã³ãã衚瀺ã§ããŸãã ãã®ãµã€ãã«ã¯ãjwtããŒã¯ã³ã®åœ¢æã«é¢ããã«ãŒã«ã®èª¬æããããŸãã
亀æããã»ã¹äžã«æå·åãããã«éä¿¡ãããããŒã¯ã³ã«åé¡ã¯ãããŸããã æåã¯ãå®å šãªHTTPSãã£ãã«ãä»ããŠéä¿¡ãè¡ãããããŒã¯ã³ã®åæå·åã¯åé·ã§ãããšããåæããé²ããŸãã 確èªããå¿ èŠãããã®ã¯ãã¯ã©ã€ã¢ã³ãåŽã§ããŒã¯ã³ã眮æãŸãã¯æ¹ãããããŠããªãããšã ãã§ãããã®ããã眲åãååŸããŠãµãŒããŒã§æ€èšŒããã ãã§ååã§ãã ãŸããããŒã¯ã³ã«ã¯éèŠãªæ å ±ã¯å«ãŸããŠããŸããã
IDããŒã¯ã³ã«å ããŠããŠãŒã¶ãŒã«çºè¡ããããã©ã³ãã«é¢ããæ å ±ãå«ãã¢ã¯ã»ã¹ããŒã¯ã³ããããŸãã ã¢ã¯ã»ã¹ããŒã¯ã³ã®çé£ã¯ããªãœãŒã¹ãžã®äžæ£ã¢ã¯ã»ã¹ãæäŸããå¯èœæ§ããããããã¢ã¯ã»ã¹ããŒã¯ã³ã®æå¹æ§ã¯éåžžã«çãã§ãã ã€ãŸããæ»æè ããã®ã¿ã€ãã®ããŒã¯ã³ãååŸã§ããå Žåãéåžžã«çãæéã§ã¢ã¯ã»ã¹ã§ããããã«ãªããŸãã æ°ããã¢ã¯ã»ã¹ããŒã¯ã³ãååŸããã«ã¯ãéåžžã¯å®å šã§ãªãç°å¢ã§ã¯è¡šç€ºãããªãæŽæ°ããŒã¯ã³ã䜿çšãããŸããç¹ã«ããã©ãŠã¶ã¢ã¯ã»ã¹ã¢ãŒãã§ã¯ãŸã£ãã䜿çšãããŸããã èªèšŒããã»ã¹äžã«ã¯ã©ã€ã¢ã³ãã«è¿ãããæ£ç¢ºãªããŒã¯ã³ã«ã€ããŠã¯ã次ã®ããŒãã§ç解ããŸãã
äž»ãªåé
ããŒã¯ã³ã®æšæºãã£ãŒã«ããšãã®å¿ èŠæ§ã«ã€ããŠç°¡åã«èª¬æããŸãã
- iss-蚌ææ©é¢ã®ã¢ãã¬ã¹ãŸãã¯ååã
- sub-ãŠãŒã¶ãŒIDã å°ãªããšãèªèšŒã»ã³ã¿ãŒå ã§äžæã§ãã
- aud-ããŒã¯ã³ãçºè¡ãããã¯ã©ã€ã¢ã³ãã®ååã
- exp-ããŒã¯ã³ã®æå¹æéã
- nbf-䜿çšå¯èœãªéå§æå»ïŒãã以åïŒã
- iat-ããŒã¯ã³çºè¡æéã
- jti-ããŒã¯ã³ã®äžæã®èå¥åïŒããŒã¯ã³ãå床ããªãªãŒã¹ãã§ããªãããã«ããããã«å¿ èŠã§ãïŒã
ååã®ãŸãšã
ãã®èšäºã§ã¯ã次ã®èšäºã§å®çšçãªãœãªã¥ãŒã·ã§ã³ãäœæããããã«å¿ èŠãªçè«çããã³çšèªçãªåºç€ãæäŸããããšããŸããã
ã楜ãã¿ã«ã
第äºéšã®ãã¿ãã¬
Identity Serverã®ã¢ããªã±ãŒã·ã§ã³ãžã®æå°éã®å®è£
çµ±åã¯æ¬¡ã®ããã«ãªããŸãã
Identity Serverãšã®Webã¯ã©ã€ã¢ã³ãçµ±åã®æå°éã®å®è£ ïŒ
Identity Serverãšã®Web APIçµ±åã®æå°éã®å®è£ ïŒ
public void Configuration(IAppBuilder app) { var factory = new IdentityServerServiceFactory(); factory.UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()) .UseInMemoryUsers(Users.Get()); var options = new IdentityServerOptions { SiteName = Constants.IdentityServerName, SigningCertificate = Certificate.Get(), Factory = factory, }; app.UseIdentityServer(options); }
Identity Serverãšã®Webã¯ã©ã€ã¢ã³ãçµ±åã®æå°éã®å®è£ ïŒ
public void Configuration(IAppBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { ClientId = Constants.ClientName, Authority = Constants.IdentityServerAddress, RedirectUri = Constants.ClientReturnUrl, ResponseType = "id_token", Scope = "openid email", SignInAsAuthenticationType = "Cookies", }); }
Identity Serverãšã®Web APIçµ±åã®æå°éã®å®è£ ïŒ
public void Configuration(IAppBuilder app) { app.UseIdentityServerBearerTokenAuthentication( new IdentityServerBearerTokenAuthenticationOptions { Authority = Constants.IdentityServerAddress, RequiredScopes = new[] { "write" }, ValidationMode = ValidationMode.Local, // credentials for the introspection endpoint ClientId = "write", ClientSecret = "secret" }); app.UseWebApi(WebApiConfig.Register()); }