Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JICS2017_HS10_OAuth2_ritou
Search
ritou
September 15, 2017
Technology
3
210
JICS2017_HS10_OAuth2_ritou
ritou
September 15, 2017
Tweet
Share
More Decks by ritou
See All by ritou
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
2
1.9k
パスキー導入の課題と ベストプラクティス、今後の展望
ritou
12
4.1k
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 + α
ritou
1
93
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
4
1.7k
OIDF-J EIWG 振り返り
ritou
2
52
そのQRコード、安全ですか? / Cross Device Flow
ritou
4
530
MIXI Mと社内外のサービスを支える認証基盤を作るためにやってきたこと #MTDC2024
ritou
3
620
Passkeys and Identity Federation @ OpenID Summit Tokyo 2024
ritou
2
820
Webアプリ開発者向け パスキー対応の始め方
ritou
4
6.5k
Other Decks in Technology
See All in Technology
(非公式) AWS Summit Japan と 海浜幕張 の歩き方 2025年版
coosuke
PRO
1
310
BigQuery Remote FunctionでLooker Studioをインタラクティブ化
cuebic9bic
2
150
監視のこれまでとこれから/sakura monitoring seminar 2025
fujiwara3
8
1.4k
自分を理解するAI時代の準備 〜マイプロフィールMCPの実装〜
edo_m18
0
110
AIのAIによるAIのための出力評価と改善
chocoyama
0
140
~宇宙最速~2025年AWS Summit レポート
satodesu
0
150
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
51
30k
TerraformをSaaSで使うとAzureの運用がこんなに楽ちん!HCP Terraformって何?
mnakabayashi
0
240
Create a Rails8 responsive app with Gemini and RubyLLM
palladius
0
130
DenoとJSRで実現する最速MCPサーバー開発記 / Building MCP Servers at Lightning Speed with Deno and JSR
yamanoku
1
160
JSX - 歴史を振り返り、⾯⽩がって、エモくなろう
pal4de
3
1k
Long journey of Continuous Delivery at Mercari
hisaharu
1
230
Featured
See All Featured
For a Future-Friendly Web
brad_frost
179
9.8k
Balancing Empowerment & Direction
lara
1
320
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
The Language of Interfaces
destraynor
158
25k
A Modern Web Designer's Workflow
chriscoyier
693
190k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
123
52k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Embracing the Ebb and Flow
colly
86
4.7k
GraphQLとの向き合い方2022年版
quramy
46
14k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Producing Creativity
orderedlist
PRO
346
40k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Transcript
1 OAuth 2.0 基礎 ritou JICS 2017
2 Ryo Ito • Evangelist @ OpenID Foundation Japan •
Engineer @ mixi, Inc. XFLAG Studio • ritou @ Twitter, facebook, github
3 本日の内容 • 概要 • OAuth 2.0とは? • OAuth 2.0の登場人物
• ユースケース • 仕様 • プロトコルフロー解説 • Authorization Code Grant
4 概要
5 OAuth 2.0とは? あるサービスが持つリソースに対し、 別のサービスがリソースオーナーの許可を得 てアクセスするためのしくみ
6 OAuth 2.0の登場人物 • Resource Owner • サービスのエンドユーザーやサービスそのもの •Client :
リソースアクセスを行うサービス • Webサービス、モバイルアプリケーション等 • Resource Server :リソースアクセスを提供する • Authorization Server : アクセス許可を与える
7 OAuth 2.0のユースケース • 登場人物である4者が存在(重複しても良い) • リソースアクセスに対し、リソースオーナーの許 可が求められる •HTTPリクエスト等でリソースアクセスが提供さ れる
8 OAuth 2.0のユースケース(1) ブログサービスからSNSに自動投稿 • Resource Owner : SNSのユーザー •
Client : ブログサービス • Resource / Authorization Server : SNS SNSが提供する機能をそのまま利用
9 OAuth 2.0のユースケース(2) イベントサービスにSNSアカウントでログイン • Resource Owner : SNSのユーザー •
Client : イベントサービス • Resource / Authorization Server : SNS プロフィール情報閲覧機能を認証用途で利用
10 OAuth 2.0のユースケース(3) SNSが機能毎にモバイルアプリケーションを提供 • Resource Owner : SNSのユーザー、SNS •
Client : SNSのモバイルアプリケーション • Resource / Authorization Server : SNS SNSが提供する機能を個別に利用
11 RFCs @ IETF OAuth WG
12 基本となる2つの仕様 • RFC 6749 The OAuth 2.0 Authorization Framework
• リソースアクセスの許可を得るまでの処理 • RFC 6750 The OAuth 2.0 Authorization Framework: Bearer Token Usage • Bearer Tokenを用いたリソースアクセス
13 その他の仕様 • OAuth 2.0 + Identity Layer = OpenID
Connect • ユースケースごとのプロファイル • OpenID Foundation : FAPI WG
14 【PR】@IT デジタルID最新動向 連載開始
15 プロトコルフロー解説
16 取り上げるユースケース ブログサービスからSNSに自動投稿 • Resource Owner : SNSのユーザー • Client
: ブログサービス • Resource / Authorization Server : SNS
17 実例 : はてなブログとfacebook はてなブログからFacebookに自動投稿 • Resource Owner : Facebookのユーザー
• Client : はてなブログ • Resource / Authorization Server : Facebook
18 アクセス許可の流れ
19 リソースアクセスに対する許可要求
20 0. Client Registration はてなブログはFacebookに対して記事共有を求めるため、 事前に手続きを済ませる • Client Type :
"confidential" • CredentialsをWebサーバーで管理 • Client Credentials • Client ID : 識別子 • Client Secret : 秘密鍵のようなもの
21 Authorization Code Grant(Flow)
22 1. Authorization Request GET /authorize? response_type=code& client_id=s6BhdRkqt3& state=xyz& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fc
b HTTP/1.1 Host: server.example.com Authorization Code Grantを利用
23 1. Authorization Request GET /authorize? response_type=code& client_id=s6BhdRkqt3& state=xyz& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fc
b HTTP/1.1 Host: server.example.com Clientの識別子と戻り先
24 1. Authorization Request GET /authorize? response_type=code& client_id=s6BhdRkqt3& state=xyz& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fc
b HTTP/1.1 Host: server.example.com CSRF対策として セッションに紐付いた値 を指定
25 Authorization Code Grant(Flow)
26 2. Authorization Response HTTP/1.1 302 Found Location: https://client.example.com/cb? code=SplxlOBeZQQYbYS6WxSbIA&
state=xyz 戻り先に クエリパラメータを付与
27 2. Authorization Response HTTP/1.1 302 Found Location: https://client.example.com/cb? code=SplxlOBeZQQYbYS6WxSbIA&
state=xyz CSRF対策の値を引回す
28 2. Authorization Response HTTP/1.1 302 Found Location: https://client.example.com/cb? code=SplxlOBeZQQYbYS6WxSbIA&
state=xyz
29 Authorization Code Grant(Flow)
30 3. Access Token Request POST /token HTTP/1.1 Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=authorization_code& code=SplxlOBeZQQYbYS6WxSbIA& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb Authorization Code Grantを利用
31 3. Access Token Request POST /token HTTP/1.1 Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=authorization_code& code=SplxlOBeZQQYbYS6WxSbIA& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb Client Credentials を指定
32 3. Access Token Request POST /token HTTP/1.1 Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=authorization_code& code=SplxlOBeZQQYbYS6WxSbIA& redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 取得したAuthorization Codeと戻り先を指定
33 Authorization Code Grant(Flow)
34 4. Access Token Response {"access_token":"2YotnFZFEjr1zCsicMWpAA", "token_type":"Bearer", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value"}
RFC6750で定義されてい る Bearer Token であることを示す
35 4. Access Token Response {"access_token":"2YotnFZFEjr1zCsicMWpAA", "token_type":"Bearer", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value"}
Access Tokenの値と 有効期限
36 4. Access Token Response {"access_token":"2YotnFZFEjr1zCsicMWpAA", "token_type":"Bearer", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value"}
Access Tokenの値を更新 (再取得)するための Refresh Token
37 リソースアクセス実行
38 Accessing Protected Resources GET /resource HTTP/1.1 Host: server.example.com Authorization:
Bearer 2YotnFZFEjr1zCsicMWpAA
39 scopeについて • リソースの範囲、提供する機能を示すもの
40 scopeについて • Authorization/Resouce Server 側が定義、実装 • 例 : SNS
• プロフィール情報の閲覧 • 友人へのメッセージ送信 •範囲は細かく指定できる方が良い •Resource Ownerへの見せ方も重要 •「(Client)があなたのプロフィール情報へのアク セスを要求しています。許可しますか?」
41 scopeについて • Client が用途に合わせて選択し、Authorization Request に含む • 必要以上に幅広い scope
を要求すべきではない • ❌プロフィール情報を利用した占いサービスが友人と のダイレクトメッセージの閲覧権限を要求
42 ここまでのまとめ • OAuth 2.0は様々なユースケースに適用可能 • 最も一般的な実装例を用いてプロトコルフローを 紹介した •scopeは重要
43 ここからは「OpenID Connectについて」