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
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
150
Project layout patterns in Go
masci
1
560
A Python and a Gopher walk into a bar - Embedding Python in Go. (dotGo2017)
masci
0
860
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
270
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
150
Django 1.7 on App Engine
masci
0
250
If code is poetry, then documentation is prose
masci
0
210
Other Decks in Programming
See All in Programming
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.6k
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
500
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
共通化で考えるべきは、実装より公開する型だった
codeegg
0
240
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
500
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
640
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
120
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
130
act1-costs.pdf
sumedhbala
0
230
継続モナドとリアクティブプログラミング
yukikurage
3
600
えっ!!コードを読まずに開発を!?
hananouchi
0
210
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
860
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
390
Side Projects
sachag
455
43k
Technical Leadership for Architectural Decision Making
baasie
3
440
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
Paper Plane (Part 1)
katiecoart
PRO
1
9.7k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
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