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
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 + α
ritou
0
59
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
4
1.6k
OIDF-J EIWG 振り返り
ritou
2
34
そのQRコード、安全ですか? / Cross Device Flow
ritou
4
410
MIXI Mと社内外のサービスを支える認証基盤を作るためにやってきたこと #MTDC2024
ritou
3
510
Passkeys and Identity Federation @ OpenID Summit Tokyo 2024
ritou
2
740
Webアプリ開発者向け パスキー対応の始め方
ritou
4
6.2k
様々なユースケースに利用できる "パスキー" の 導入事例の紹介とUXの課題解説 @ DroidKaigi 2023
ritou
3
4.7k
パスキーはユーザー認証を どう変えるのか?その特徴と導入における課題 @ devsumi 2023 9-C-1
ritou
6
13k
Other Decks in Technology
See All in Technology
20250129 Findy_テスト高活用化
dshirae
0
230
事業継続を支える自動テストの考え方
tsuemura
0
150
Agentic AI時代のプロダクトマネジメントことはじめ〜仮説検証編〜
masakazu178
3
440
自動と手動の両輪で開発するデータクレンジング
estie
2
110
攻撃者の視点で社内リソースはどう見えるのかを ASMで実現する
hikaruegashira
4
2.1k
CNAPPから考えるAWSガバナンスの実践と最適化
yuobayashi
5
700
ObservabilityCON on the Road Tokyoの見どころ
hamadakoji
0
240
マルチデータプロダクト開発・運用に耐えるためのデータ組織・アーキテクチャの遷移
mtpooh
1
330
ゆもつよがこの30年間自ら経験してきたQA、テストの歴史と未来
ymty
2
240
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
18k
カスタムインストラクションでGitHub Copilotをカスタマイズ!
07jp27
8
1.4k
ChatGPTを使ったブログ執筆と校正の実践テクニック/登壇資料(井田 献一朗)
hacobu
1
170
Featured
See All Featured
Code Review Best Practice
trishagee
65
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Producing Creativity
orderedlist
PRO
343
39k
For a Future-Friendly Web
brad_frost
176
9.5k
A Tale of Four Properties
chriscoyier
158
23k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Bash Introduction
62gerente
610
210k
Statistics for Hackers
jakevdp
797
220k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
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について」