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
230
3
Share
JICS2017_HS10_OAuth2_ritou
ritou
September 15, 2017
More Decks by ritou
See All by ritou
[PR] はじめてのデジタルアイデンティティという本を書きました
ritou
2
1.1k
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
2
6.6k
パスキー導入の課題と ベストプラクティス、今後の展望
ritou
12
7.6k
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
トイルを超えたCREは何屋になるのか
bengo4com
0
110
自分をひらくと次のチャレンジの敷居が下がる
sudoakiy
3
1.1k
MCPで決済に楽にする
mu7889yoon
0
160
Cursor Subagentsはいいぞ
yug1224
2
130
「できない」のアウトプット 同人誌『精神を壊してからの』シリーズ出版を 通して得られたこと
comi190327
3
440
OPENLOGI Company Profile for engineer
hr01
1
61k
契約書からの情報抽出を行うLLMのスループットを、バッチ処理を用いて最大40%改善した話
sansantech
PRO
3
330
Even G2 クイックスタートガイド(日本語版)
vrshinobi1
0
160
MIX AUDIO EN BROADCAST
ralpherick
0
140
「活動」は激変する。「ベース」は変わらない ~ 4つの軸で捉える_AI時代ソフトウェア開発マネジメント
sentokun
0
140
OCI技術資料 : 証明書サービス概要
ocise
1
7.2k
AWS Systems Managerのハイブリッドアクティベーションを使用したガバメントクラウド環境の統合管理
toru_kubota
1
190
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
150
Tell your own story through comics
letsgokoyo
1
880
The Spectacular Lies of Maps
axbom
PRO
1
660
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Designing for Timeless Needs
cassininazir
0
180
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Designing Powerful Visuals for Engaging Learning
tmiket
1
320
エンジニアに許された特別な時間の終わり
watany
106
240k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
160
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
870
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
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について」