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
83
Project layout patterns in Go
masci
1
500
A Python and a Gopher walk into a bar - Embedding Python in Go. (dotGo2017)
masci
0
750
A Python and a Gopher walk into a bar - Embedding Python in Go.
masci
0
250
How to port your Python software to Go without people noticing
masci
0
210
Python - Go One Way
masci
0
180
How we stopped using the mouse and started drawing molecules with our fingertips: not the usual porting story
masci
0
100
Django 1.7 on App Engine
masci
0
200
If code is poetry, then documentation is prose
masci
0
120
Other Decks in Programming
See All in Programming
個人開発の学生アプリが企業譲渡されるまで
akidon0000
2
1.2k
ぽちぽち選択するだけでOSSを読めるVSCode拡張機能
ymbigo
14
6.5k
読書シェア会 vol.4 『ダイナミックリチーミング 第2版』
kotaro666
0
120
エンジニアが挑む、限界までの越境
nealle
1
330
2025年のz-index設計を考える
tak_dcxi
12
4.7k
ウォンテッドリーの「ココロオドル」モバイル開発 / Wantedly's "kokoro odoru" mobile development
kubode
2
630
ComposeでのPicture in Picture
takathemax
0
140
Designing Your Organization's Test Pyramid ( #scrumniigata )
teyamagu
PRO
5
1.5k
エンジニア向けCursor勉強会 @ SmartHR
yukisnow1823
3
13k
ASP.NETアプリケーションのモダナイゼーションについて
tomokusaba
0
260
Duke on CRaC with Jakarta EE
ivargrimstad
1
140
The New Developer Workflow: How AI Transforms Ideas into Code
danielsogl
0
140
Featured
See All Featured
Building Adaptive Systems
keathley
41
2.5k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Statistics for Hackers
jakevdp
799
220k
Navigating Team Friction
lara
185
15k
Raft: Consensus for Rubyists
vanstee
137
6.9k
KATA
mclloyd
29
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
The Language of Interfaces
destraynor
158
25k
Making Projects Easy
brettharned
116
6.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Six Lessons from altMBA
skipperchong
28
3.8k
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