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.7k
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
AWS DevOps Agent or Kiro の使いどころを考える_20260402
masakiokuda
0
140
FlutterでPiP再生を実装した話
s9a17
0
240
Databricks Lakehouse Federationで 運用負荷ゼロのデータ連携
nek0128
0
100
制約を設計する - 非決定性との境界線 / Designing constraints
soudai
PRO
4
610
マルチモーダル非構造データとの闘い
shibuiwilliam
1
130
SSoT(Single Source of Truth)で「壊して再生」する設計
kawauso
2
410
スクラムを支える内部品質の話
iij_pr
0
160
Bref でサービスを運用している話
sgash708
0
220
Blue/Green Deployment を用いた PostgreSQL のメジャーバージョンアップ
kkato1
1
210
VSCode中心だった自分がターミナル沼に入門した話
sanogemaru
0
890
【AWS】CloudTrail LakeとCloudWatch Logs Insightsの使い分け方針
tsurunosd
0
130
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
5
1.3k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Agile that works and the tools we love
rasmusluckow
331
21k
A better future with KSS
kneath
240
18k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
sira's awesome portfolio website redesign presentation
elsirapls
0
200
Raft: Consensus for Rubyists
vanstee
141
7.4k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.1k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
240
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
230
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について」