å®ēØēćŖćµć³ćć«ćØć㦠OAuth ć®ććć¤ćć®å³ć UML ć§č”Øē¾ćć¾ćć
OAuth 㯠RFC 6749 ć®åŗęŗć§ćć GitHub ć® Web Application Flow ćåčć«ćć¦ćć¾ćć
Component
å½¹å²ććØć®ć³ć³ćć¼ćć³ćććććććć®ćć¼ćć«é ē½®ććć¦ćć¾ćć
actor "User"
node "Application" {
[Client]
}
node "API" {
[Resource]
}
node "Authentication" {
[AuthN]
}
node "Authorization" {
[AuthZ]
}
[User].[Client]
[User]..[AuthN]
[User]..[AuthZ]
[AuthN]..[AuthZ]
[Client]..[AuthN]
[Client]..[AuthZ]
[Client].[Resource]
Sequence
ćć¼ćććć£ćć¤ćć巄夫ćććØć·ć¼ć±ć³ć¹ćč§£ćććććŖćć¾ćć
actor User
== Initial ==
User -> Client : Request Client Sign In
note right : GET /user/sign_in
activate Client
Client -> Client : Access Token?
== Authentication ==
Client -> AuthN : Redirect
note right : GET /oauth/authorize
deactivate Client
activate AuthN
AuthN -> AuthN : Current User?
AuthN -> AuthN : Redirect
note right : GET /user/sign_in
User <- AuthN : Response AuthN Sign In
deactivate AuthN
User -> AuthN : Request AuthN Sign In (ID, Pass)
activate AuthN
note right : POST /user/sign_in
AuthN -> AuthN : Redirect
note right : GET /oauth/authorize
== Authorization ==
AuthN -> AuthZ : Redirect
note right : GET /oauth/authorize
deactivate AuthN
activate AuthZ
User <- AuthZ : Response AuthZ Application
deactivate AuthZ
User -> AuthZ : Request AuthZ Application (Allow)
note right : POST /oauth/authorize
activate AuthZ
AuthZ -> AuthZ : Generate Code
Client <- AuthZ : Redirect
note right : GET /callback
deactivate AuthZ
activate Client
Client -> AuthZ : Request Access Token
note right : POST /oauth/access_token
activate AuthZ
AuthZ -> AuthZ : Authorization Code?
AuthZ -> AuthZ : Generate Token
Client <-- AuthZ : Response Access Token
deactivate AuthZ
Client -> Client : Redirect
note right : GET /user/sign_in
Client -> Client : Access Token?
== Resource ==
Client -> Resource : Request User (Access Token)
note right : GET /api/user
activate Resource
Client <-- Resource : Response User
deactivate Resource
== Final ==
Client -> Client : Redirect
note right : GET /
User <- Client : Response Client Sign In
deactivate Client
å®éć® OAuth ć® Flow ćØåć£ć¦ććć㯠GitHub ććµć¤ć³ć¢ć¦ćććē¶ę ć§ćććć« Qiita ćŖć©ć®ćµć¼ćć¹ććµć¤ć³ć¢ć¦ćććē¶ę ćććµć¤ć³ć¤ć³ććŖćÆćØć¹ććć¦ē¢ŗčŖćć¦ćć ćććļ¼ćć§ć« Authorized ććććµć¼ćć¹ćÆćć”ćć§ Revoke ććåæ č¦ćććć¾ććļ¼