SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Kort om RFC6749
OAuth2
Emil Tullstedt
<emil@46elks.com>
@sakjur
Uppsala Tech Meetup
2015-09-22
Problem
1 Applikationer som vill komma ˚at resurser som tillh¨or en
anv¨andare p˚a en extern server beh¨over autentisera sig med
anv¨andarens inloggningsuppgifter1
2 Det ¨ar sv˚art f¨or anv¨andaren att begr¨ansa vilka resurser en viss
applikation har tillg˚ang till
3 Anv¨andaren m˚aste byta l¨osenord f¨or att bryta en applikations
tillg˚ang till resurserna
1
L¨osenord i klartext <3
OAuth2 f¨or anv¨andaren
F¨or webbutvecklare, tl;dr; OAuth2?
1 Anv¨anda annan leverant¨or f¨or att logga in → Slippa l¨osenord
2 APIer! Google, GitHub, Facebook, et.c.
3 OAuth2 ≈ OpenID Connect
Nyckelbegrepp
Resurs¨agare I normalfallet, anv¨andaren
Resursserver Server med resurs¨agarens resurser
Klient Applikation som f¨ors¨oker n˚a resurser
Auktoriseringsserver Server f¨or att autentisera klienten
Auktoriseringsf¨orfr˚agan Klienten ber resurs¨agaren om en grant
Auktoriseringsgrant Klienten byter ut mot en Accesstoken
Accesstoken Nyckeln f¨or att komma ˚at resurser
H¨amta en accesstoken
Klient Auktoriseringsserver
Resurs¨agare
Resursserver
A
B
A B
B
C
C
D
H¨amta en accesstoken – Anrop
Klienten instruerar resurs¨agaren att med en user-agent2 g˚a in p˚a en
specifik auktoriseringssida.
User-Agent → Auktoriseringsserver
1 GET /authorize?response_type=code&client_id=s6BhdRkqt3&
state=xyz&redirect_uri=https%3A%2F%2Fclient%2Eexample
%2Ecom%2Fcb HTTP/1.1
2 Host: server.example.com
2
User-Agent ¨ar motsvarande en webbl¨asare
H¨amta en accesstoken – Anrop
Auktoriseringsserver → User-Agent
1 HTTP/1.1 302 Found
2 Location: https://client.example.com/cb?code=
SplxlOBeZQQYbYS6WxSbIA&state=xyz
User-Agent → Klient
GET /cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
H¨amta en accesstoken – Anrop
Klient → Auktoriseringsserver
1 POST /token HTTP/1.1
2 Host: server.example.com
3 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
4 Content-Type: application/x-www-form-urlencoded
5
6 grant_type=authorization_code&code=
SplxlOBeZQQYbYS6WxSbIA&redirect_uri=https%3A%2F%2
Fclient%2Eexample%2Ecom%2Fcb
Basic Authorization i OAuth2?
Klienten auktoriserar sig mot auktoriseringsservern med hj¨alp av
basic auth
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
H¨amta en accesstoken – Anrop
Auktoriseringsserver → Klient
1 HTTP/1.1 200 OK
2 Content-Type: application/json;charset=UTF-8
3 Cache-Control: no-store
4 Pragma: no-cache
5
6 {
7 "access_token":"2YotnFZFEjr1zCsicMWpAA",
8 "token_type":"example",
9 "expires_in":3600,
10 "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
11 "example_parameter":"example_value"
12 }
H¨amta en accesstoken – i praktiken
Bibliotek! o/
Komma ˚at en resurs med en token
1 Beror p˚a tokentyp
2 Bearer token-formatet beskrivs av RFC6750
3 RFC6749 n¨amner ¨aven OAuth-HTTP-MAC3
1 GET /resource/1 HTTP/1.1
2 Host: example.com
3 Authorization: Bearer mF_9.B5f-4.1JqM
3
Fortfarande i utkastsstadiet
Hur l¨ange lever en Accesstoken
1 Livsl¨angden p˚a en accesstoken anges eventuellt av
expires in-variabeln fr˚an auktoriseringsservern
2 Ny accesstoken kan h¨amtas med en refreshtoken
3 Resurs¨agaren kan dra in en klients accesser
1 {
2 · · ·
3 "expires_in":3600,
4 "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
5 · · ·
6 }
R¨attigheter
1 Klienten kan inkludera en variabel scope i sin
auktoriseringsf¨orfr˚aga
2 scope ¨ar bara en mellanslagsseparerad lista
3 Auktoriseringsservern ¨ar fri att tolka scope hur den vill
tl;dr;
1 OAuth2 hj¨alper dina anv¨andare att logga in och dig att
anv¨anda deras externa resurser
2 RFC6749 f˚ar OAuth2 att verka jobbigare ¨an det ¨ar i
verkligheten
Fr˚agor?
emil@46elks.com
@sakjur
L¨ankar
1 RFC6749 OAuth2
https://tools.ietf.org/html/rfc6749
2 RFC6750 Bearer Token
https://tools.ietf.org/html/rfc6750
3 OAuth-HTTP-MAC Draft 05
https://tools.ietf.org/html/
draft-ietf-oauth-v2-http-mac-05
4 Googles OAuth 2.0 dokumentation
https://developers.google.com/identity/
protocols/OAuth2
5 requests-oauthlib (Python-bibliotek f¨or att leka med OAuth)
https://requests-oauthlib.readthedocs.org/

Mais conteúdo relacionado

Destaque

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destaque (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

OAuth2 på Svenska

  • 1. Kort om RFC6749 OAuth2 Emil Tullstedt <emil@46elks.com> @sakjur Uppsala Tech Meetup 2015-09-22
  • 2. Problem 1 Applikationer som vill komma ˚at resurser som tillh¨or en anv¨andare p˚a en extern server beh¨over autentisera sig med anv¨andarens inloggningsuppgifter1 2 Det ¨ar sv˚art f¨or anv¨andaren att begr¨ansa vilka resurser en viss applikation har tillg˚ang till 3 Anv¨andaren m˚aste byta l¨osenord f¨or att bryta en applikations tillg˚ang till resurserna 1 L¨osenord i klartext <3
  • 4. F¨or webbutvecklare, tl;dr; OAuth2? 1 Anv¨anda annan leverant¨or f¨or att logga in → Slippa l¨osenord 2 APIer! Google, GitHub, Facebook, et.c. 3 OAuth2 ≈ OpenID Connect
  • 5. Nyckelbegrepp Resurs¨agare I normalfallet, anv¨andaren Resursserver Server med resurs¨agarens resurser Klient Applikation som f¨ors¨oker n˚a resurser Auktoriseringsserver Server f¨or att autentisera klienten Auktoriseringsf¨orfr˚agan Klienten ber resurs¨agaren om en grant Auktoriseringsgrant Klienten byter ut mot en Accesstoken Accesstoken Nyckeln f¨or att komma ˚at resurser
  • 6. H¨amta en accesstoken Klient Auktoriseringsserver Resurs¨agare Resursserver A B A B B C C D
  • 7. H¨amta en accesstoken – Anrop Klienten instruerar resurs¨agaren att med en user-agent2 g˚a in p˚a en specifik auktoriseringssida. User-Agent → Auktoriseringsserver 1 GET /authorize?response_type=code&client_id=s6BhdRkqt3& state=xyz&redirect_uri=https%3A%2F%2Fclient%2Eexample %2Ecom%2Fcb HTTP/1.1 2 Host: server.example.com 2 User-Agent ¨ar motsvarande en webbl¨asare
  • 8. H¨amta en accesstoken – Anrop Auktoriseringsserver → User-Agent 1 HTTP/1.1 302 Found 2 Location: https://client.example.com/cb?code= SplxlOBeZQQYbYS6WxSbIA&state=xyz User-Agent → Klient GET /cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
  • 9. H¨amta en accesstoken – Anrop Klient → Auktoriseringsserver 1 POST /token HTTP/1.1 2 Host: server.example.com 3 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 4 Content-Type: application/x-www-form-urlencoded 5 6 grant_type=authorization_code&code= SplxlOBeZQQYbYS6WxSbIA&redirect_uri=https%3A%2F%2 Fclient%2Eexample%2Ecom%2Fcb
  • 10. Basic Authorization i OAuth2? Klienten auktoriserar sig mot auktoriseringsservern med hj¨alp av basic auth Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
  • 11. H¨amta en accesstoken – Anrop Auktoriseringsserver → Klient 1 HTTP/1.1 200 OK 2 Content-Type: application/json;charset=UTF-8 3 Cache-Control: no-store 4 Pragma: no-cache 5 6 { 7 "access_token":"2YotnFZFEjr1zCsicMWpAA", 8 "token_type":"example", 9 "expires_in":3600, 10 "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", 11 "example_parameter":"example_value" 12 }
  • 12. H¨amta en accesstoken – i praktiken Bibliotek! o/
  • 13. Komma ˚at en resurs med en token 1 Beror p˚a tokentyp 2 Bearer token-formatet beskrivs av RFC6750 3 RFC6749 n¨amner ¨aven OAuth-HTTP-MAC3 1 GET /resource/1 HTTP/1.1 2 Host: example.com 3 Authorization: Bearer mF_9.B5f-4.1JqM 3 Fortfarande i utkastsstadiet
  • 14. Hur l¨ange lever en Accesstoken 1 Livsl¨angden p˚a en accesstoken anges eventuellt av expires in-variabeln fr˚an auktoriseringsservern 2 Ny accesstoken kan h¨amtas med en refreshtoken 3 Resurs¨agaren kan dra in en klients accesser 1 { 2 · · · 3 "expires_in":3600, 4 "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", 5 · · · 6 }
  • 15. R¨attigheter 1 Klienten kan inkludera en variabel scope i sin auktoriseringsf¨orfr˚aga 2 scope ¨ar bara en mellanslagsseparerad lista 3 Auktoriseringsservern ¨ar fri att tolka scope hur den vill
  • 16. tl;dr; 1 OAuth2 hj¨alper dina anv¨andare att logga in och dig att anv¨anda deras externa resurser 2 RFC6749 f˚ar OAuth2 att verka jobbigare ¨an det ¨ar i verkligheten
  • 18. L¨ankar 1 RFC6749 OAuth2 https://tools.ietf.org/html/rfc6749 2 RFC6750 Bearer Token https://tools.ietf.org/html/rfc6750 3 OAuth-HTTP-MAC Draft 05 https://tools.ietf.org/html/ draft-ietf-oauth-v2-http-mac-05 4 Googles OAuth 2.0 dokumentation https://developers.google.com/identity/ protocols/OAuth2 5 requests-oauthlib (Python-bibliotek f¨or att leka med OAuth) https://requests-oauthlib.readthedocs.org/