authentik.sources.oauth.types.reddit
Reddit OAuth Views
1"""Reddit OAuth Views""" 2 3from typing import Any 4 5from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient 6from authentik.sources.oauth.types.registry import SourceType, registry 7from authentik.sources.oauth.views.callback import OAuthCallback 8from authentik.sources.oauth.views.redirect import OAuthRedirect 9 10 11class RedditOAuthRedirect(OAuthRedirect): 12 """Reddit OAuth2 Redirect""" 13 14 def get_additional_parameters(self, source): # pragma: no cover 15 return { 16 "scope": ["identity"], 17 "duration": "permanent", 18 } 19 20 21class RedditOAuth2Callback(OAuthCallback): 22 """Reddit OAuth2 Callback""" 23 24 client_class = UserprofileHeaderAuthClient 25 26 27@registry.register() 28class RedditType(SourceType): 29 """Reddit Type definition""" 30 31 callback_view = RedditOAuth2Callback 32 redirect_view = RedditOAuthRedirect 33 verbose_name = "Reddit" 34 name = "reddit" 35 36 authorization_url = "https://www.reddit.com/api/v1/authorize" 37 access_token_url = "https://www.reddit.com/api/v1/access_token" # nosec 38 profile_url = "https://oauth.reddit.com/api/v1/me" 39 40 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 41 return { 42 "username": info.get("name"), 43 "email": None, 44 "name": info.get("name"), 45 }
12class RedditOAuthRedirect(OAuthRedirect): 13 """Reddit OAuth2 Redirect""" 14 15 def get_additional_parameters(self, source): # pragma: no cover 16 return { 17 "scope": ["identity"], 18 "duration": "permanent", 19 }
Reddit OAuth2 Redirect
22class RedditOAuth2Callback(OAuthCallback): 23 """Reddit OAuth2 Callback""" 24 25 client_class = UserprofileHeaderAuthClient
Reddit OAuth2 Callback
client_class =
<class 'authentik.sources.oauth.clients.oauth2.UserprofileHeaderAuthClient'>
28@registry.register() 29class RedditType(SourceType): 30 """Reddit Type definition""" 31 32 callback_view = RedditOAuth2Callback 33 redirect_view = RedditOAuthRedirect 34 verbose_name = "Reddit" 35 name = "reddit" 36 37 authorization_url = "https://www.reddit.com/api/v1/authorize" 38 access_token_url = "https://www.reddit.com/api/v1/access_token" # nosec 39 profile_url = "https://oauth.reddit.com/api/v1/me" 40 41 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 42 return { 43 "username": info.get("name"), 44 "email": None, 45 "name": info.get("name"), 46 }
Reddit Type definition
callback_view =
<class 'RedditOAuth2Callback'>
redirect_view =
<class 'RedditOAuthRedirect'>
access_token_url =
'https://wwwauthentik.sources.oauth.types.reddit.com/api/v1/access_token'
profile_url =
'https://oauthauthentik.sources.oauth.types.reddit.com/api/v1/me'
def
get_base_user_properties(self, info: dict[str, typing.Any], **kwargs) -> dict[str, typing.Any]:
41 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 42 return { 43 "username": info.get("name"), 44 "email": None, 45 "name": info.get("name"), 46 }
Get base user properties for enrollment/update