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
2
520
About_JWT_at_NDS_39_Niigata_pm
NDS#39 Niigata.pm tech talk
http://connpass.com/event/8695/
で発表した資料です。
ritou
December 13, 2014
Tweet
Share
More Decks by ritou
See All by ritou
[PR] はじめてのデジタルアイデンティティという本を書きました
ritou
1
900
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
2
6.1k
パスキー導入の課題と ベストプラクティス、今後の展望
ritou
12
7.1k
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 + α
ritou
1
150
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
4
1.8k
OIDF-J EIWG 振り返り
ritou
2
92
そのQRコード、安全ですか? / Cross Device Flow
ritou
4
640
MIXI Mと社内外のサービスを支える認証基盤を作るためにやってきたこと #MTDC2024
ritou
3
780
Passkeys and Identity Federation @ OpenID Summit Tokyo 2024
ritou
2
970
Other Decks in Technology
See All in Technology
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
660
コミュニティが変えるキャリアの地平線:コロナ禍新卒入社のエンジニアがAWSコミュニティで見つけた成長の羅針盤
kentosuzuki
0
130
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
380
1,000 にも届く AWS Organizations 組織のポリシー運用をちゃんとしたい、という話
kazzpapa3
0
110
コンテナセキュリティの最新事情 ~ 2026年版 ~
kyohmizu
5
1k
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
680
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
4
1.4k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
160
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
220
Context Engineeringの取り組み
nutslove
0
380
AIエージェントに必要なのはデータではなく文脈だった/ai-agent-context-graph-mybest
jonnojun
1
230
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
330
Featured
See All Featured
Amusing Abliteration
ianozsvald
0
100
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
420
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Utilizing Notion as your number one productivity tool
mfonobong
3
220
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
83
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
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