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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ritou
September 15, 2017
Technology
230
3
Share
JICS2017_HS10_OAuth2_ritou
ritou
September 15, 2017
More Decks by ritou
See All by ritou
[PR] はじめてのデジタルアイデンティティという本を書きました
ritou
2
1.2k
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
2
6.7k
パスキー導入の課題と ベストプラクティス、今後の展望
ritou
12
7.8k
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 + α
ritou
1
170
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
4
1.8k
OIDF-J EIWG 振り返り
ritou
2
100
そのQRコード、安全ですか? / Cross Device Flow
ritou
4
660
MIXI Mと社内外のサービスを支える認証基盤を作るためにやってきたこと #MTDC2024
ritou
3
800
Passkeys and Identity Federation @ OpenID Summit Tokyo 2024
ritou
2
1k
Other Decks in Technology
See All in Technology
60分で学ぶ最新Webフロントエンド
mizdra
PRO
34
18k
[OpsJAWS 40]リリースしたら終わり、じゃなかった。セキュリティ空白期間をAWS Security Agentで埋める
sh_fk2
3
220
最新の脅威動向から考える、コンテナサプライチェーンのリスクと対策
kyohmizu
1
680
みんなの「データ活用」を支えるストレージ担当から持ち込むAWS活用/コミュニティー設計TIPS 10選~「作れる」より、「続けられる」設計へ~
yoshiki0705
0
230
Do Ruby::Box dream of Modular Monolith?
joker1007
1
320
AI時代のガードレールとしてのAPIガバナンス
nagix
0
220
昔はシンプルだった_AmazonS3
kawaji_scratch
0
320
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
300
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
23k
最近の技術系の話題で気になったもの色々(IoT系以外も) / IoTLT 花見予定会(たぶんBBQ) @都立潮風公園バーベキュー広場
you
PRO
1
220
Master Dataグループ紹介資料
sansan33
PRO
1
4.6k
AzureのIaC管理からログ調査まで、随所に役立つSkillsとCustom-Instructions / Boosting IaC and Log Analysis with Skills
aeonpeople
0
200
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
Designing Powerful Visuals for Engaging Learning
tmiket
1
340
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
200
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Abbi's Birthday
coloredviolet
2
7k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
810
Skip the Path - Find Your Career Trail
mkilby
1
110
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
130
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
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について」