Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHP 也有 Day #48:我是誰?我在哪?
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Star Rocket
October 01, 2019
Technology
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP 也有 Day #48:我是誰?我在哪?
PHP 也有 Day #48:我是誰?我在哪?
Star Rocket
October 01, 2019
Transcript
65 slides
我是誰︖我在哪︖ 聊聊 Web 的身分驗證
ABOUT MILES CURRENT Senior Developer @ 104 Corp. Volunteer @
DevOps Taiwan TAG PHP, Docker, DevOps
[email protected]
MilesChou
None
今天將會聊些什麼 Terminology Scenario Native App Security Topic
Terminology Authentication Entity Identifier
Server User
Server User Entity
Server User Entity Identifier
Server User Entity Identifier Miles Miles
Server User Entity Identifier Authentication Miles Miles
基本的安全問題 請求真的是該使⽤者本身的意願所發出的請求嗎︖ 有沒有可能被竄改︖有沒有機會造假︖ 回應真的是伺服器的回應嗎︖ 有沒有可能被竄改︖有沒有機會造假︖
Scenario 從前從前,有個網站提供了很多服務
安安你好,第⼀一次來來嗎? 第⼀一次來來的都是絕緣⼈人哦! 為了了讓你不再絕緣, 你先跟我講好,要怎麼驗證你是誰!
註冊的⽬的 使⽤者提供憑證資訊,如帳號、密碼、etc 伺服器提供 metadata
註冊的⽅法 線上註冊 私訊註冊 線下註冊
User Login 身為⼀個使⽤者,我希望能使⽤網站提供的服務
安安你好,第⼆二次來來嗎? 站著!⼝口令?誰? 我知道你是麥爾斯了了,可是我⾦金金⿂魚腦! 24 分鐘內記得過來來刷新⼀一下!
User Login Challenge State Management Mechanism
實作 Laravel Auth Zend Authentication
Server-side Authentication 身為⼀個伺服器,我希望能呼叫網站提供的 API
How about Authorization?
Server-side Authentication Trusted Server VPN、鎖 IP、發 token、etc. OAuth 2.0 Facebook、Google、GitHub、AWS、etc.
Terminology - OAuth 2.0 Authorization Resource Owner Resource Server Client
Authorization Server
Authorization Server Resource Owner Resource Server Client Authorization Request
Authorization Server Resource Owner Resource Server Client Authorization Grant
Authorization Server Resource Owner Resource Server Client Authorization Grant
Authorization Server Resource Owner Resource Server Client Access Token
Authorization Server Resource Owner Resource Server Client Access Token
Authorization Server Resource Owner Resource Server Client Protected Resource
微信偷連結 Facebook︖ 到底花⽣省魔術︖請看 VCR!
微信偷連結 Facebook︖ Facebook 實作了 OAuth 2.0 微信 App 為 Client
授權範圍
Third-party Login 身為⼀個外部網站,我希望能透過貴站做身分驗證
安安你好,你是麥爾斯的跟班嗎? 有刷過麥爾斯的臉就可以進場了了哦! 但過⼀一回兒後, 我還會再跟麥爾斯確認,你還是不是他的跟班
Third-party Login OAuth 2.0 Facebook, Google, GitHub, etc. OpenID Connect
AppleID, Line, Google, Auth0, etc. SAML GitHub, Google, etc.
Server User Provider Authentication Check
OpenID Connect
OpenID Connect Based-on OAuth 2.0 Use JWT on ID token
Discovery Dynamic Client Registration
Authorization Server Client End User Login
Authorization Server Client End User Redirect to Authorization Server scope=openid
Authorization Server Client End User Authorization Request
GET / POST
Authorization Server Client End User Challenge
Authorization Server Client End User User Credentials
Authorization Server Client End User Authorization Request
Authorization Server Client End User Authorization Grant
Authorization Server Client End User Redirect to Client with Code
Authorization Server Client End User Use Code to get Access
Token ID Token
ID token
簽章 圖⽚來源:https://en.wikipedia.org/wiki/File:Private_key_signing.svg
簽章演算法 HS256 - HMVC using SHA-256 Line RS256 - RSASSA-PKCS1-v1_5
using SHA-256 AppleID, Google ES256 - ECDSA using P-256 and SHA-256 AppleID
Discovery AppleID Line Google
⽤用講的不就很會? 做⼀一個來來看看啊!
Demo
Native App
先講結論 不要⽤嵌入式 User Agent,即麻煩又危險 可使⽤ PKCE 來解決這個問題
Chrome on Mobile 圖⽚來源:https://www.ory.sh/oauth2-for-mobile-app-spa-browser/
App on Mobile 圖⽚來源:https://www.ory.sh/oauth2-for-mobile-app-spa-browser/
Security Topic
基本 TLS CSRF XSS CSP Same-origin Policy
HTML 登入 無標準協定 網路釣⿂
Covert Redirect Redirect url 驗證
清除登入狀態 Token Revoke 的時機 OpenID Session Management Front-Channel Logout Back-Channel
Logout
Extra - Password 千萬不要存明碼 MD5 與 SHA1 已被認為是不安全的演算法 建議使⽤ SHA256
Extra - Cookie 問題核⼼在於過度依賴 Cookie 作為身分驗證的⼿段 CSRF Session Hijacking Session
Fixation Weak Confidentiality Weak Integrity
Q & A
More Decks by Star Rocket
See All by Star Rocket
PHP 也有 Day #51:高效能框架的曙光 - 以 Laravel 經驗開發 Hyperf 應用
starrocket
1
430
PHP 也有 Day #50:處理前人的遺產—聊 legacy code
starrocket
0
140
PHP 也有 Day #49:邊緣人救星!用 Laravel 打造私人定製的聊天機器人
starrocket
0
510
PHP 也有 Day #48:我是誰?我在哪?
starrocket
0
150
API-整合測試
starrocket
0
210
How we talk about Engineering Culture at Phase
starrocket
0
110
PHP 也有 Day #47:打造好維護的 PHP 程式碼專案
starrocket
0
450
全端起手就用 Laravel+Vue.js 現場實作給你看
starrocket
0
280
PHP 也有 Day #45: VS Code 實戰料理 PHP 套件網站佐 Azure Pipelines
starrocket
0
220
Other Decks in Technology
See All in Technology
Microsoft Entra Kerberos で実現するクラウド デバイス管理
tamaiyutaro
2
670
evcc & Home Assistant
naltatis
0
620
Kiro Crew 入門 (手を離しても進む仕事) | 目指せ Kiro マスター 11
inariku
PRO
4
720
「いつか使う」の「いつか」は来ない 〜AI駆動開発における「作らない」判断について〜
ikki0006
0
200
うちなーぐちが認識できるなら、秋田弁もいけるはず!? Amazon Transcribe方言チューニング検証
ryouto715
1
170
並列度を下げたら速くなった — go build の重複コンパイルを実測で見る
tomoaki25
2
1.2k
狙われているAPIの脆弱性!今こそ手をつけるべき根本的な対策とは?
nagix
0
120
属人化したISMS運用をGitHubとAIで仕組み化した1年間の記録
sioncojp
4
2.5k
会社説明資料_最新版
demaecan
0
32k
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
280
[JAWS Festa 2026]一番いい仕事は、請求書に現れない / jawsfesta2026
sh_fk2
2
500
AI時代に求められる優秀なTechLeadの振る舞い
pospome
11
16k
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
340
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How STYLIGHT went responsive
nonsquared
100
6.4k
Music & Morning Musume
bryan
48
7.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Utilizing Notion as your number one productivity tool
mfonobong
4
640
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Cult of Friendly URLs
andyhume
79
7.1k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Deep Space Network (abreviated)
tonyrice
0
410