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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Massimiliano Pippi
April 10, 2015
Programming
200
0
Share
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
130
Project layout patterns in Go
masci
1
550
A Python and a Gopher walk into a bar - Embedding Python in Go. (dotGo2017)
masci
0
830
A Python and a Gopher walk into a bar - Embedding Python in Go.
masci
0
340
How to port your Python software to Go without people noticing
masci
0
250
Python - Go One Way
masci
0
240
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
230
If code is poetry, then documentation is prose
masci
0
190
Other Decks in Programming
See All in Programming
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
140
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
510
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.6k
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
270
How Swift's Type System Guides AI Agents
koher
0
270
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
Kingdom of the Machine
yui_knk
2
330
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
180
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
200
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
Designing Experiences People Love
moore
143
24k
Done Done
chrislema
186
16k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
69
39k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
We Have a Design System, Now What?
morganepeng
55
8.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Tell your own story through comics
letsgokoyo
1
900
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
320
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