Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Adding support for client credential oauth clients #91

Merged
merged 1 commit into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sqlshare_rest/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def get_oauth_user(request):
request=request):
raise Exception("Invalid token - no user")

if "client-credentials" == request.client.authorization_grant_type:
request.user = request.client.user

if not request.user:
raise Exception("Invalid token - no user")

Expand Down
2 changes: 2 additions & 0 deletions sqlshare_rest/views/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class SSRegistrationForm(forms.ModelForm):
"""
GRANT_AUTHORIZATION_CODE = 'authorization-code'
GRANT_IMPLICIT = 'implicit'
GRANT_CLIENT_CREDENTIALS = 'client-credentials'
GRANT_TYPES = (
(GRANT_AUTHORIZATION_CODE, 'Authorization code'),
(GRANT_IMPLICIT, 'Implicit'),
(GRANT_CLIENT_CREDENTIALS, 'Client credentials'),
)

# Limit the allowed grant types
Expand Down