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
About_JWT_at_NDS_39_Niigata_pm
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ritou
December 13, 2014
Technology
550
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
About_JWT_at_NDS_39_Niigata_pm
NDS#39 Niigata.pm tech talk
http://connpass.com/event/8695/
で発表した資料です。
ritou
December 13, 2014
More Decks by ritou
See All by ritou
FAPIの立ち位置はどう変わる? ~多様化するユースケースを支えるセキュアAPIエコノミー~
ritou
1
19
“ID沼入口” - 基本とセキュリティから始める、考え続けるためのID管理技術勉強会 告知&イントロ
ritou
0
600
認証認可だけじゃない! ID管理の構成要素と ライフサイクルを意識しよう
ritou
1
770
[PR] はじめてのデジタルアイデンティティという本を書きました
ritou
2
1.4k
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
2
7.4k
パスキー導入の課題と ベストプラクティス、今後の展望
ritou
12
9k
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 + α
ritou
1
200
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
4
1.9k
OIDF-J EIWG 振り返り
ritou
2
130
Other Decks in Technology
See All in Technology
1000⼈規模のClaude Enterprise運⽤を「Oktaのグループ」と「Slack」に集約する
sansantech
PRO
1
500
:syncing_time:
sksat
3
840
『自分で判断できるか』を基準に、プロダクトのハンズオン研修でAI利用の線を引いてみた / Where We Drew the Line on AI in Hands-on Training
honyanya
1
440
AI駆動開発を組織で促すために
lycorptech_jp
PRO
7
8.7k
Digital Credentials API × OpenID4VP ブラウザ完結型本人確認の実装知見(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
340
EMの役割で 変わったこと・変わらなかったこと
sansantech
PRO
1
190
カーネルまで探検して理解するふたつの自動計装
sumiyae
0
340
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
130
PdMをやめて、 "プロダクトビルダー"という 働き方に変えました / PdM to Product Builder
shikichee
1
130
Introduction to Bill One Development Engineer
sansan33
PRO
0
480
みてねにおけるAI-DLC導入活動とAIドリブン開発の現在地/JAWS-UG AI-DLC #2
isaoshimizu
2
280
tamachi.goを支える技術
rymiyamoto
0
110
Featured
See All Featured
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
290
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
490
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
480
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Mobile First: as difficult as doing things right
swwweet
225
10k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
350
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Paper Plane
katiecoart
PRO
2
53k
Exploring anti-patterns in Rails
aemeredith
3
480
Transcript
1
• • • • 2
3
4
• • • • • 5
6
eyJ .eyJ . 7
[Encoded Header] [Encoded Payload] [Encoded Signature] 8
{"alg":"HS256","typ":"JWT"} 9
{"name":"ritou","title":"About JSON Web Token","date":"2014-12-13"} 10
“Encoded Header + ‘.’ + Encoded Payload” eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicml0b 3UiLCJ0aXRsZSI6IkFib3V0IEpTT04gV2ViIFRva2VuIiwiZGF0ZSI6I jIwMTQtMTItMTMifQ
11
12
13
14
• JWS(JSON Web Signature) : 署名つき • • JWA(JSON Web
Algorithm) : 署名生成/暗号化の アルゴリズム • JWK(JSON Web Key) : 鍵まわり 15
16
• • • • • • 17
18
19
20
• 21
iss [ID Tokenの発行元] sub [ユーザーID] aud [ID Tokenの発行先] 22
• • • 23
24
25
26
• • • • 27
$options->{id} はセッションID(ランダムな文字列) $options->{id} $options->{id} 28
my $cookie = crush_cookie($env->{HTTP_COOKIE} || '')->{$self- >{cookie_name}}; my $session =
$self->{store}->get($cookie) or return; $session = $self->{serializer}->[1]->($session) if $self->{serializer}; 29
• • Session IDを含むJWS • • JWS検証後 30
::JWSCookie $options->{id} はセッションID(ランダムな文字列) my $jws = encode_jwt({ id => $options->{id}
}, $self->secret, $self->alg); $jws $jws 31
::JWSCookie my $cookie = crush_cookie($env->{HTTP_COOKIE} || '')->{$self->{cookie_name}}; # JWSの検証 $payload
= decode_jwt($cookie, $self->secret, 0); 32
::JWSCookie my $id = $payload->{id}; my $session = $self->{store}->get($id) or
return; 33
• • • • 34
35
http://d.hatena.ne.jp/ritou/20140927/1411811648 36
• • • 37
38
• • • • • 39
40
• • • • • 41
42
• • • 43
44
• • • 45
• • • 46
47