mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-03 23:49:16 +02:00
Support oauth token in URL
This commit is contained in:
parent
e3b0efb25f
commit
c8fcf1b0d9
4 changed files with 62 additions and 19 deletions
25
api/funkwhale_api/users/oauth/server.py
Normal file
25
api/funkwhale_api/users/oauth/server.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import urllib.parse
|
||||
import oauthlib.oauth2
|
||||
|
||||
|
||||
class OAuth2Server(oauthlib.oauth2.Server):
|
||||
def verify_request(self, uri, *args, **kwargs):
|
||||
valid, request = super().verify_request(uri, *args, **kwargs)
|
||||
if valid:
|
||||
return valid, request
|
||||
|
||||
# maybe the token was given in the querystring?
|
||||
query = urllib.parse.urlparse(request.uri).query
|
||||
token = None
|
||||
if query:
|
||||
parsed_qs = urllib.parse.parse_qs(query)
|
||||
token = parsed_qs.get("token", [])
|
||||
if len(token) > 0:
|
||||
token = token[0]
|
||||
|
||||
if token:
|
||||
valid = self.request_validator.validate_bearer_token(
|
||||
token, request.scopes, request
|
||||
)
|
||||
|
||||
return valid, request
|
Loading…
Add table
Add a link
Reference in a new issue