mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
Use caps keys to store discord secrets in flask session object
This commit is contained in:
@@ -11,4 +11,4 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.1.01"
|
__version__ = "0.1.02"
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class DiscordOAuth2HttpClient(abc.ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
SESSION_KEYS = [
|
SESSION_KEYS = [
|
||||||
"discord_oauth2_state",
|
"DISCORD_OAUTH2_STATE",
|
||||||
"discord_oauth2_token",
|
"DISCORD_OAUTH2_TOKEN",
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
@@ -38,7 +38,7 @@ class DiscordOAuth2HttpClient(abc.ABC):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _token_updater(token):
|
def _token_updater(token):
|
||||||
session["discord_oauth2_token"] = token
|
session["DISCORD_OAUTH2_TOKEN"] = token
|
||||||
|
|
||||||
def _make_session(self, token: str = None, state: str = None, scope: list = None) -> OAuth2Session:
|
def _make_session(self, token: str = None, state: str = None, scope: list = None) -> OAuth2Session:
|
||||||
"""A low level method used for creating OAuth2 session.
|
"""A low level method used for creating OAuth2 session.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
|
|||||||
scope = scope or request.args.get("scope", str()).split() or configs.DEFAULT_SCOPES
|
scope = scope or request.args.get("scope", str()).split() or configs.DEFAULT_SCOPES
|
||||||
discord_session = self._make_session(scope=scope)
|
discord_session = self._make_session(scope=scope)
|
||||||
authorization_url, state = discord_session.authorization_url(configs.AUTHORIZATION_BASE_URL)
|
authorization_url, state = discord_session.authorization_url(configs.AUTHORIZATION_BASE_URL)
|
||||||
session["discord_oauth2_state"] = state
|
session["DISCORD_OAUTH2_STATE"] = state
|
||||||
return redirect(authorization_url)
|
return redirect(authorization_url)
|
||||||
|
|
||||||
def callback(self):
|
def callback(self):
|
||||||
@@ -53,7 +53,7 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
|
|||||||
client_secret=self.client_secret,
|
client_secret=self.client_secret,
|
||||||
authorization_response=request.url
|
authorization_response=request.url
|
||||||
)
|
)
|
||||||
session["discord_oauth2_token"] = token
|
session["DISCORD_OAUTH2_TOKEN"] = token
|
||||||
|
|
||||||
def revoke(self):
|
def revoke(self):
|
||||||
"""This method clears current discord token, state and all session data from flask
|
"""This method clears current discord token, state and all session data from flask
|
||||||
|
|||||||
Reference in New Issue
Block a user