Use caps keys to store discord secrets in flask session object

This commit is contained in:
thecosmos
2019-05-26 10:56:15 +05:30
parent 1b2932f1b0
commit 9d5cbcdd77
3 changed files with 6 additions and 6 deletions

View File

@@ -11,4 +11,4 @@ __all__ = [
]
__version__ = "0.1.01"
__version__ = "0.1.02"

View File

@@ -25,8 +25,8 @@ class DiscordOAuth2HttpClient(abc.ABC):
"""
SESSION_KEYS = [
"discord_oauth2_state",
"discord_oauth2_token",
"DISCORD_OAUTH2_STATE",
"DISCORD_OAUTH2_TOKEN",
]
def __init__(self, app):
@@ -38,7 +38,7 @@ class DiscordOAuth2HttpClient(abc.ABC):
@staticmethod
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:
"""A low level method used for creating OAuth2 session.

View File

@@ -35,7 +35,7 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
scope = scope or request.args.get("scope", str()).split() or configs.DEFAULT_SCOPES
discord_session = self._make_session(scope=scope)
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)
def callback(self):
@@ -53,7 +53,7 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
client_secret=self.client_secret,
authorization_response=request.url
)
session["discord_oauth2_token"] = token
session["DISCORD_OAUTH2_TOKEN"] = token
def revoke(self):
"""This method clears current discord token, state and all session data from flask