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
Protect a Django REST api with Oauth2
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Massimiliano Pippi
April 10, 2015
Programming
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Protect a Django REST api with Oauth2
Lightning talk for pycon15
Massimiliano Pippi
April 10, 2015
More Decks by Massimiliano Pippi
See All by Massimiliano Pippi
Finding the needle: a deep dive into the rewriting of Haystack
masci
0
140
Project layout patterns in Go
masci
1
560
A Python and a Gopher walk into a bar - Embedding Python in Go. (dotGo2017)
masci
0
850
A Python and a Gopher walk into a bar - Embedding Python in Go.
masci
0
360
How to port your Python software to Go without people noticing
masci
0
260
Python - Go One Way
masci
0
250
How we stopped using the mouse and started drawing molecules with our fingertips: not the usual porting story
masci
0
140
Django 1.7 on App Engine
masci
0
240
If code is poetry, then documentation is prose
masci
0
200
Other Decks in Programming
See All in Programming
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
190
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
110
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.3k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
Inside Stream API
skrb
1
740
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
200
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
1B+ /day規模のログを管理する技術
broadleaf
0
100
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
130
A2UI という光を覗いてみる
satohjohn
1
140
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
150
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Cult of Friendly URLs
andyhume
79
6.9k
Embracing the Ebb and Flow
colly
88
5.1k
How GitHub (no longer) Works
holman
316
150k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
980
Deep Space Network (abreviated)
tonyrice
0
210
Transcript
Protect a Django REST API with OAuth2 Massimiliano Pippi @maxpippi
Introducing my friend Harold Let’s say we want to write
a timetracking web application y u not pushing? git push -f works lol
Backend recipe Django & Django REST Framework u can use
the new DRF3 generic views here wut?
Projects proliferation timetracker-backend timetracker-web timetracker-[android|ios] timetracker-desktop yep! I need an
app for my nokia 3210
How do we do access control? Third party apps want
to access our data as well! not ma problem can’t hear u
Common problems • Using user credentials inside the app is
a bad idea • The app might have full access to user account • User has to change his password to revoke the access
Multiple problems - one Solution The OAuth2 framework omg not
oauth again
Django OAuth Toolkit • Django 1.4 → 1.7 (1.8 coming
soon) • Python 2&3 • built on top of oauthlib, RFC 6749 compliant • DRF 2&3 integration https://github.com/evonove/django-oauth-toolkit
Batteries included • builtin views to register and manage OAuth2
applications • form view for user authorization lol I found what DRF stands for omg harold plz retire
Endpoints protection for the lazy • function views decorators @protected_resource()
def my_view(request): # A valid token is required to get here… • generic class based views class ApiEndpoint(ProtectedResourceView): def get(self, request, *args, **kwargs): return HttpResponse('Hello, OAuth2!')
DRF ootb integration REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'oauth2_provider.ext.rest_framework.OAuth2Authentication', )
}
Future plans - Help needed! OAuth1 support Resource and Authorization
server components separation https://github.com/evonove/django-oauth-toolkit +1 for my own PR