How to bake delicious cookie (RESTful Meetup #03)Toru Yamaguchi
Toru Yamaguchi gave a presentation on advanced cookie usage. He explained the differences between host cookies and domain cookies, and how the path attribute can be used to control where cookies are sent. He discussed how JSON web tokens (JWT) can be used for login sessions by embedding user agent information. Finally, he mentioned how transparent session state cookies allow for single logout between authorization servers and client applications.
1. The document discusses various issues that can cause failures when building APIs to access database systems, such as deadlocks from concurrent updates and purging data inconsistencies between master and slave databases.
2. It proposes solutions to these issues like using queues to defer updates, disabling binary logging to bypass replication, and partitioning or sharding data.
3. When building a friend timeline API, challenges include efficiently querying the necessary data across multiple database tables to return a paginated result with the total count. Solutions presented include using temporary tables and iteration in batches to query the data.
Inside mbga Open Platform API architectureToru Yamaguchi
The document describes a load balancer distributing requests across multiple lighttpd web servers running fastcgi applications. It also shows databases for user profiles and messages with memcached caching. Messages are enqueued into a message queue processed by worker processes and inserted into a replicated message database with a slave for high availability. Cached messages from previous lookups are stored in memcached for improved performance.
The document discusses OpenID authentication and describes the flow between an Identity Provider and OpenID Provider. It includes code snippets for retrieving an XRDS document from an OpenID and generating an HMAC signature. The overall document provides information about OpenID authentication standards and protocols.
El documento describe una reunión tecnológica sobre OpenID. La reunión incluirá presentaciones sobre temas relacionados con OpenID como autenticación y autorización. También habrá tiempo para preguntas y discusión.
Generating Automatic Feedback on UI Mockups with Large Language Models
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
1. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
OAuth 2.0
Web Messaging
Response Mode
OpenID Summit 2015
November
10,
2015
Toru
Yamaguchi
Senior
Architect
Sub
Business
Unit
Head
Open
Pla=orm
Business
Unit
DeNA
Co.,
Ltd.
3. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
本⽇日の概要
! OAuth
2.0
の
Authorization
Endpoint
からのレスポンスの受信形式
として新しいドラフトである
OAuth
2.0
Web
Messaging
Response
Mode
を作ったので、それの詳細について以下の流流れで解説します
! OAuth
2.0
の
Redirect
URI
について
! OAuth
2.0
Form
Post
Response
Mode
! OAuth
2.0
Web
Messaging
Response
Mode
3
4. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
OAuth
2.0
と
Redirect
URI
OAuth
2.0
Web
Messaging
Response
Mode
4
5. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
OAuth
2.0
とは本質的に何をやりたい枠組みなのか
! もの凄く簡略略化して⾔言えば、Client
が
(End
User
の権限を持つ)
Access
Token
を
Authorization
Server
から得るためのフレームワークが
OAuth
2.0
だと⾔言えます
⁃ その結果得た
Access
Token
を⽤用いて
Protected
Resource
(要は
API)
にアクセスする
5
End
User
AuthorizaDon
Server
Client
1.
Redierct
to
AuthorizaDon
Request
2.
AuthorizaDon
Request
3.
AuthorizaDon
Response
4.
Redirect
to
Redirect
URI
5.
Token
Request
6.
Token
Response
6. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Code
Grant
のシーケンス
! Authorization
Response
は
Redirect
URI
に対する
UserAgent
を介し
た
HTTP
リダイレクションで渡される
6
hQp://goo.gl/kfZTNY
7. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Request
! 上記は
RFC
6749
での
Authorization
Code
Grant
での
Authorization
Request
のサンプルです
7
GET
/authorize?
response_type=code&
client_id=s6BhdRkqt3&
state=xyz&
redirect_uri=https%3A%2F%2Fclient%2Eexample
%2Ecom%2Fcb
HTTP/1.1
Host:
server.example.com
8. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Response
! 上記は
RFC
6749
での
Authorization
Code
Grant
での
Authorization
Response
のサンプルです
8
HTTP/1.1
302
Found
Location:
https://client.example.com/cb?
code=SplxlOBeZQQYbYS6WxSbIA&
state=xyz
9. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
Implicit
Grant
のシーケンス
! Implicit
Grant
は
Token
Response
が
Authorization
Endpoint
から
HTTP
リダイレクションで返って来る
⁃ Access
Token
などは
URI
Fragment
(#
以下の⽂文字列列)
として
返って来るため
JavaScript
などによる
parse
が必要
9
hQp://goo.gl/95ddOd
10. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
Redirect
URI
と問題点
! 様々ありますが例例えば以下のような課題があります
⁃ User
Agent
を介した
HTTP
リダイレクションのため、中間者攻
撃が成⽴立立し得る
⁃ HTTP
リダイレクションが発⽣生するため
UX
が
Single
Page
Application
向きではない
⁃ Implicit
の場合は
Protected
Resource
にアクセスするための
Access
Token
が
JavaScript
などで触れる領領域に渡されるため、
XSS
などで
Access
Token
そのものが奪われるリスクがある
! 今回の
Web
Message
Response
Mode
は上記のような課題感がモチ
ベーションになっています
10
11. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
OAuth
2.0
Form
Post
Response
Mode
OAuth
2.0
Web
Messaging
Response
Mode
11
12. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
Form
Post
Response
Mode
とは何か?
! Spec
⁃ https://openid.net/specs/oauth-‐‑‒v2-‐‑‒form-‐‑‒post-‐‑‒response-‐‑‒
mode-‐‑‒1_̲0.html
! Authorization
Endpoint
からのレスポンスを
HTTP
リダイレクショ
ンではなく、JavaScript
を⽤用いた
form
の⾃自動
POST
に差し替えたもの
! まずはプロトコルについて流流れを追ってみましょう
12
13. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Code
Grant
のシーケンス
/w
form
post
! Authorization
Response
の渡し⽅方が
form
の⾃自動
submit
になって
います
⁃ それ以外は本質的な違いはありません
13
hQp://goo.gl/3ci98I
14. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Request
! 通常の
Authorization
Request
と異異なる点は
response_̲mode
に
form_̲post
という値を指定している点です
14
GET
/authorize?
response_type=id_token
&response_mode=form_post
&client_id=some_client
&scope=openid
&redirect_uri=https%3A%2F
%2Fclient.example.org%2Fcallback
&state=DcP7csa3hMlvybERqcieLHrRzKBra
&nonce=2T1AgaeRTGTMAJyeDMN9IJbgiUG
HTTP/1.1
Host:
server.example.com
15. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Request
! 通常の
Authorization
Request
と異異なる点は
response_̲mode
に
form_̲post
という値を指定している点です
15
GET
/authorize?
response_type=id_token
&response_mode=form_post
&client_id=some_client
&scope=openid
&redirect_uri=https%3A%2F
%2Fclient.example.org%2Fcallback
&state=DcP7csa3hMlvybERqcieLHrRzKBra
&nonce=2T1AgaeRTGTMAJyeDMN9IJbgiUG
HTTP/1.1
Host:
server.example.com
16. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Response
(1)
! 指定された
Redirect
URI
に対して
HTTP
メソッドの
POST
で⾃自動的に
Submit
するようなレスポンスを返します
16
HTTP/1.1
200
OK
Content-‐Type:
text/html;charset=UTF-‐8
Cache-‐Control:
no-‐cache,
no-‐store
Pragma:
no-‐cache
<html>
<head><title>Submit
This
Form</title></head>
<body
onload="javascript:document.forms[0].submit()">
<form
method="post"
action="https://client.example.org/callback">
<input
type="hidden"
name="state"
value="DcP7csa3hMlvybERqcieLHrRzKBra"/>
<input
type="hidden"
name="id_token"
value="eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzdWIiOiJqb2huIiw
iYXVkIjoiZmZzMiIsImp0aSI6ImhwQUI3RDBNbEo0c2YzVFR2cllxUkIiLC
Jpc3MiOiJodHRwczpcL1wvbG9jYWxob3N0OjkwMzEiLCJpYXQiOjEzNjM5M
DMxMTMsImV4cCI6MTM2MzkwMzcxMywibm9uY2UiOiIyVDFBZ2FlUlRHVE1B
SnllRE1OOUlKYmdpVUciLCJhY3IiOiJ1cm46b2FzaXM6bmFtZXM6dGM6U0F
NTDoyLjA6YWM6Y2xhc3NlczpQYXNzd29yZCIsImF1dGhfdGltZSI6MTM2Mz
kwMDg5NH0.c9emvFayy-‐YJnO0kxUNQqeAoYu7sjlyulRSNrru1ySZs2qwqq
wwq-‐Qk7LFd3iGYeUWrfjZkmyXeKKs_OtZ2tI2QQqJpcfrpAuiNuEHII-‐_fk
IufbGNT_rfHUcY3tGGKxcvZO9uvgKgX9Vs1v04UaCOUfxRjSVlumE6fWGcq
XVEKhtPadj1elk3r4zkoNt9vjUQt9NGdm1OvaZ2ONprCErBbXf1eJb4NW_h
nrQ5IKXuNsQ1g9ccT5DMtZSwgDFwsHMDWMPFGax5Lw6ogjwJ4AQDrhzNCFc
0uVAwBBb772-‐86HpAkGWAKOK-‐wTC6ErRTcESRdNRe0iKb47XRXaoz5acA"/>
</form>
</body>
</html>
17. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
AuthorizaGon
Response
(2)
! JavaScript
が実⾏行行された結果、UserAgent
は上記のようなリクエストを
Redirect
URI
に送出します
17
POST
/callback
HTTP/1.1
Host:
client.example.org
Content-‐Type:
application/x-‐www-‐form-‐urlencoded
id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzdWIiOiJqb2huIiwiYX
VkIjoiZmZzMiIsImp0aSI6ImhwQUI3RDBNbEo0c2YzVFR2cllxUkIiLCJpc
3MiOiJodHRwczpcL1wvbG9jYWxob3N0OjkwMzEiLCJpYXQiOjEzNjM5MDMx
MTMsImV4cCI6MTM2MzkwMzcxMywibm9uY2UiOiIyVDFBZ2FlUlRHVE1BSnl
lRE1OOUlKYmdpVUciLCJhY3IiOiJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTD
oyLjA6YWM6Y2xhc3NlczpQYXNzd29yZCIsImF1dGhfdGltZSI6MTM2MzkwM
Dg5NH0.c9emvFayy-‐YJnO0kxUNQqeAoYu7sjlyulRSNrru1ySZs2qwqqwwq
-‐Qk7LFd3iGYeUWrfjZkmyXeKKs_OtZ2tI2QQqJpcfrpAuiNuEHII-‐_fkIuf
bGNT_rfHUcY3tGGKxcvZO9uvgKgX9Vs1v04UaCOUfxRjSVlumE6fWGcqXVE
KhtPadj1elk3r4zkoNt9vjUQt9NGdm1OvaZ2ONprCErBbXf1eJb4NW_hnrQ
5IKXuNsQ1g9ccT5DMtZSwgDFwsHMDWMPFGax5Lw6ogjwJ4AQDrhzNCFc0uV
AwBBb772-‐86HpAkGWAKOK-‐wTC6ErRTcESRdNRe0iKb47XRXaoz5acA&
state=DcP7csa3hMlvybERqcieLHrRzKBra
18. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
Form
Post
Response
Mode
の利利点は何か
! GET
メソッドで⽤用いる
URI
の最⼤大⻑⾧長を気にしなくて良良い
⁃ RFC
では制限はないが
UserAgent
側の制限と
HTTP
Server
側
の制限がある
! サンプルの
Authorization
Request
で指定されている
response_̲type
で
id_̲token
が指定されていて、POST
で直接サーバーに渡している
点に注⽬目
⁃ 本来
URI
Fragment
で渡すのが筋
(OpenID
Connect
1.0)
⁃ つまり
Browser
相⼿手の場合は
JavaScript
で
parse
する必要があ
る
• ID
Token
は
JWT
なので
JWS
or
JWE
でエンコードされているため、あ
まりユースケースが無いと⾔言える
⁃ ⼀一⽅方
Form
Post
を⽤用いた場合は
Implicit
相当の⼿手続きで
ID
Token
を
Server
に渡す事が出来る
! response_̲mode
という新しい語彙を定義した
⁃ 要するにこれが⾔言いたかっただけです!
18
19. Copyright
(C)
DeNA
Co.,Ltd.
All
Rights
Reserved.
OAuth
2.0
Web
Messaging
Response
Mode
OAuth
2.0
Web
Messaging
Response
Mode
19