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
0
170
Protect a Django REST api with Oauth2
Lightning talk for pycon15
Massimiliano Pippi
April 10, 2015
Tweet
Share
More Decks by Massimiliano Pippi
See All by Massimiliano Pippi
Finding the needle: a deep dive into the rewriting of Haystack
masci
0
68
Project layout patterns in Go
masci
1
490
A Python and a Gopher walk into a bar - Embedding Python in Go. (dotGo2017)
masci
0
740
A Python and a Gopher walk into a bar - Embedding Python in Go.
masci
0
240
How to port your Python software to Go without people noticing
masci
0
200
Python - Go One Way
masci
0
170
How we stopped using the mouse and started drawing molecules with our fingertips: not the usual porting story
masci
0
87
Django 1.7 on App Engine
masci
0
190
If code is poetry, then documentation is prose
masci
0
110
Other Decks in Programming
See All in Programming
チームリードになって変わったこと
isaka1022
0
200
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
1年目の私に伝えたい!テストコードを怖がらなくなるためのヒント/Tips for not being afraid of test code
push_gawa
0
210
時計仕掛けのCompose
mkeeda
1
300
Domain-Driven Transformation
hschwentner
2
1.9k
定理証明プラットフォーム lapisla.net
abap34
1
1.8k
もう僕は OpenAPI を書きたくない
sgash708
5
1.8k
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
『品質』という言葉が嫌いな理由
korimu
0
160
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
Immutable ActiveRecord
megane42
0
140
Featured
See All Featured
Done Done
chrislema
182
16k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
Building Your Own Lightsaber
phodgson
104
6.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Cult of Friendly URLs
andyhume
78
6.2k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
How STYLIGHT went responsive
nonsquared
98
5.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
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