OAuthããã¦ãããµã¼ãã¹ãAndroid + PhoneGapçµç±ã§ä½¿ãããã¦èª¿ã¹ã¦è¦ã¾ããã
ããã¦ãè²ã
調ã¹ããèãããããçµæã
client_secret ã£ã¦ããããç§å¯éµã«ããå¿
è¦ãªããï¼ã
ã¨ãã天åãå¾ãã®ã§ãã¤ãã¤ãã¨æ¸ãã¦ã¿ã¾ããsecretã£ã¦ååãªã®ã«ç§å¯ã§ããå¿
è¦ããªããªãã¦ããããããããªããã
ééã£ã¦ãæ°ããã¦ãªããªãã®ã§ã誰ãææããã¦ãã ããããã¸ã§ã
ã¨ãããããåæã¨ãã¦èªåã®ãµã¼ãã¹ã®èªè¨¼æ¿ããã«ä½¿ããããããããªãã¦ãç´ç²ã«ãã®ãµã¼ãã¹ã使ãã®ãç®çãOAuthãªãµã¼ãã¹ã¯ãµã¼ããµã¤ãã§ä½¿ã£ããã¨ã¯ä½åº¦ããããã ãã©ãã¯ã©ã¤ã¢ã³ããµã¤ãã§ä½¿ãã¨ããäºã§ãæ±ããå°ãã®ãclient_secretãååã®éããç§å¯éµã¨ãã¦æ±ãå¿
è¦ãããã¨æã£ã¦ããã ãã©ãæ£ç´å®å
¨ã«ã¯ã©ã¤ã¢ã³ãå´ã§ç®¡çããæ¹æ³ãç¡ãã
å
¬éãã¦ããé常ã®ã½ã¼ã¹ããã¯å¤ãã¦ãã«ãæã«çµã¿è¾¼ãã®ã ã¨ãã¦ããéã¢ã»ããããçµããã ããåççã«ã»ãã¥ã¢ãããªãæ¹æ³ã¨ããã®ã¯å¤§å¤å¾®å¦ã
調ã¹ã¦ã¿ãã¨ããããããã«ãã®è¾ºã¯å½ç¶èæ
®æ¸ã¿ããããGoogleã ã¨ä¸è¨ã®ãããã¡ã¤ã«ãããã
- Web Server Applications
- Client-side Applications
- Installed Application
- Devices
Devicesã¯ãã©ã¦ã¶ã使ããªãå ´åã«ãä»ã®ç«¯æ«ã¨é£æºãã¦OAuthã使ãæ¹æ³ãä»åã¯é¢ä¿ç¡ãã®ã§ãã¹ãWeb Server Applicatoinsããµã¼ããµã¤ãã§ã®å©ç¨ãæ®ãï¼ã¤ãã¯ã©ã¤ã¢ã³ããµã¤ãã§ã®å©ç¨ã¨ãªããClient-side Applicationsã¨Installed Applicationã®
ã¦ã¼ã¹ã±ã¼ã¹ã®æ¬è³ªçãªéããä»ã²ã¨ã¤ç解ã§ãã¦ãªãã®ã ãã©ãåè
ã¯ä¸»ã«JSã§å®è£
ããããã¨ãæ³å®ãã¦ããã¿ãããä»åã®ç¦ç¹ã¯ãã®ï¼ã¤ã
ã¾ããClient-side Applicationsã¨Installed Applicationsã®ããã¼ãæ´çãã¦ã¿ãã
Client-side Applications(implicit grant flow)
- client_idã¨scopeã¨redirect_urlãå«ãURLã§èªè¨¼ãã¼ã¸ã«ã¢ã¯ã»ã¹
- åãµã¼ãã¹ã®èªè¨¼
- client_idã«ç´ã¥ãããµã¼ãã¹ã¸ã®ã¦ã¼ã¶ã®æ¿èª
- æ¿èªãè²°ããã°ãredirect_urlã«ãªãã¤ã¬ã¯ãããã®æãURLã«access_tokenãå«ã
- JSã§URLããaccess_tokenãåå¾
- access_tokenãä»ä¸ãã¦å種APIãå©ç¨
- 寿å½ãåãããæåããããç´ã
Installed Applications
- client_idã¨scopeã¨redirect_urlãå«ãURLã§èªè¨¼ãã¼ã¸ã«ã¢ã¯ã»ã¹
- åãµã¼ãã¹ã®èªè¨¼
- client_idã«ç´ã¥ãããµã¼ãã¹ã¸ã®ã¦ã¼ã¶ã®æ¿èª
- æ¿èªãè²°ããã°ãauthorization codeãè¿ã
- authorization codeã¨client_idã¨client_secretã使ç¨ãã¦ãaccess_tokenã¨refresh_tokenãåå¾
- access_tokenãä»ä¸ãã¦å種APIãå©ç¨
- 寿å½ãåãããrefresh_tokenã¨client_secretã§access_tokenãååå¾
ã¨ãã ããããããªæãã主ãªéãã¯client_secretã使ããã©ãããã¨ããããInstalled Applicationsã¯WebServerã¨åããªæ°ãããã
ããã¤ããã¼ã¯ã³ãåºã¦ããã®ã§æ´çã
åå | å¯¿å½ | æ©å¯æ§ | å½¹å² | Client-Side | Installed |
client_id |
ãªã |
å
Ž |
OAuthã¯ã©ã¤ã¢ã³ãã®èå¥ID |
ä½¿ç¨ |
ä½¿ç¨ |
client_secret |
ãªã |
ç§å¯ï¼ |
client_idã®æ£å½æ§ç¢ºèªç¨ |
æªä½¿ç¨ |
ä½¿ç¨ |
authorization code |
ãã |
ç§å¯ |
access_tokenã¨refresh_tokenã®çºè¡ç¨ |
æªä½¿ç¨ |
ä½¿ç¨ |
access_token |
ãã |
ç§å¯ |
èªè¨¼å
容ã示ããã¼ã¯ã³ |
ä½¿ç¨ |
ä½¿ç¨ |
refresh_token |
ãªã |
ç§å¯ |
access_tokenã®åçºè¡ç¨ |
æªä½¿ç¨ |
ä½¿ç¨ |
å
ç¨ã®ããã¼ã¨ãã®è¡¨ãããclient_secretã®ä¸»ãªå½¹ç®ã¯autorization codeãrefresh_tokenã¨ãã£ãç§å¯éµãclient_idã«ç´ã¥ããã®ã§ãããã¨ã®æ¤è¨¼ã ã¨ç解ã
Client-Sideã®å ´åã¯ããã®æ¤è¨¼ãè¡ããªããããrefresh_tokenãçºè¡ã§ããªããã¨ã
access_tokenã¯å¯¿å½ããããããæµåºãã¦ãã¾ã£ã¦ãã大ããªåé¡ã«ã¯ãªããªãã®ã§ãæ¤è¨¼ãªãã§ãçºè¡ãã¦ããã®ããªã
Googleã®ããã¥ã¡ã³ãã«ããthe client_secret is obviously not treated as a secret.ãã¨ããããã ãã©ããã®ããclient_secretã使ã£ã¦ããããããã§èª¿ã¹ã¦ãå°ãªããªãæ°ã®äººãã¢ããªã«åãè¾¼ãã§ãã®ã§ãclient_secretãå
¬éããã¨ãã®åé¡ãèãã¦ã¿ãã
åºæ¬çã«åæ©è½ã®èªè¨¼ããããæç¹ã§ã¯ãclient_idã®ã¿ã§OK. ã¤ã¾ãclient_secretã¯æ»ã£ã¦ããå¤ãèªåã¨å¯¾ã«ãªãclient_idã§ä½ããããã¨ãä¿è¨¼ããç¨åº¦ã®æ©è½ããç¡ãã
ãããããããã§é²ããã®ã¯
èªè¨¼ã®ãªããã¾ãåé¡ãclient_idã¨client_secretãå
¬éããã¦ããå ´åãæªæã®ãã第ä¸è
ã¯èªç±ã«èªååãã®access_tokenãçºè¡å¯è½ãã§ããä»äººã®authorization codeã¨client_secretãèªåã®ããã«ç½®ãæããã®ã¯çµæ§é£ããã®ã§ã¯ï¼ãéä¿¡çµè·¯ã¯
HTTPSã ãããã®è¾ºãã¯ã©ãã¯ããã¦ããªãããã¯ãã©ããããããªãã ãã...
次ã«èããããã®ããèªè¨¼ã®æ¨ªåãããã£ãã¨éãã®ã¯ãæ»æè
ã®ç¥ã£ã¦ãæ
å ±ã被害è
ã«ä½¿ãããã®ã§ã¯ãªãã被害è
ã®æ
å ±ãæ ãã¨ãæ¹æ³ã«é¢ãã¦ã
ããã«é¢ãã¦ã¯ãclient_idã¨client_secretãå
¬éãã¦ãåé¡ãªããcode, access_token, refresh_tokenã¨ãããµã¼ãããç´æ¥è¿ãããå¤ãé©åã«ç®¡çãããããã°ãã¢ããªãå
ã
ç¥ã£ã¦ããclient_idã¨client_secretãã©ã使ã£ãã¨ããã§ãaccess_tokenã復å
ãããã¨ã¯ã§ããªããããã管çã¨ãã¦éè¦ãªã®ã¯refresh_tokenããªãããã¯æéãç¡ãã®ã§ãããã¤ãé©åã«ç®¡çããå¿
è¦ãããã
æå¾ã«èããããã®ãã¢ããªã±ã¼ã·ã§ã³ã®ä¿¡ç¨ã®æ¨ªåããæªæã®ããã½ããã«èªã¢ããªã®client_idã使ã£ã¦å¯¾è±¡ãµã¼ãã¹ã¸ã®æ¿èªãåãããå ´åãclient_secretãåãã£ã¦ããã°access_tokenã®åå¾ã¾ã§å¯è½ãã¦ã¼ã¶ã¯ãèªåã®ä¿¡é ¼ãã¦ããã¢ããªã ã¨èª¤èªãã¦ãæ¿èªããã¦ãã¾ããã¨ãèãããããã§ããããClient-Side Applictionsã®å ´åãåããªæ°ããããªãæªæãããã½ãããèªç«¯æ«ã«å
¥ãããã¦ãããã¨åæãªã®ã§ããªãã¤ã¬ã¯ãããããµã¼ããåºå®ã¨ã¯ãããHTTPããã£ããã£ããã°æããã¬ãã«ã®æ
å ±ã ãããã¤ã
OSSã®å ´åã¯æ½å¨çã«ã³ãã¼ãã¦ã¦ã£ã«ã¹ãåãè¾¼ã¾ãããã®ãé
å¸ããããªã¹ã¯ãããããã§ã§ããããè¸ã¾ããã¨ããªã¹ã¯ãç¡ããããããªããã©ãå¾æ¥ãããªã¹ã¯ãä¸ãããããããªããã£ã¦ã®ã¯è¨ããããªã
ã¾ã¨ã
ã¨ããããã§ãèªåãèããçµæãclient_secretã¯ç§å¯éµãããªãã®ã§ã
ã½ã¼ã¹ã³ã¼ãã«åãè¾¼ãã§å
¬éãã¦åé¡ãªãï¼ãã¨ããã¢ãªã¨ãã¤çµè«ã«è³ã£ã¦ãã¾ã£ãã®ã§ã誰ãææãã¦ãã ãã...
ã»ã¨ãã©ã®å
¥éè¨äºã§åé¡æèµ·ãããããã«æ°ã«ããåãè¾¼ãã§ãã®ã§ãèæ
®æ¸ã¿ã§æ¥ç常èã£ã¦ãã¨ã§ãããã...