(20241214) testing token keys instead of direct ids.
This commit is contained in:
@@ -161,7 +161,7 @@ async def handle_gmail_callback() -> render_template:
|
||||
# if they don't match, we reject the authorization:
|
||||
auth_token = await current_app.mail_controller.get_token(
|
||||
mongo_conn = current_app.data_mongo,
|
||||
token_id = g.inbound_data["state"]
|
||||
token_key = g.inbound_data["state"]
|
||||
)
|
||||
if (
|
||||
(not auth_token) or
|
||||
@@ -218,7 +218,7 @@ async def handle_gmail_callback() -> render_template:
|
||||
db_conn = current_app.sql_writer,
|
||||
mongo_conn = current_app.data_mongo,
|
||||
session_token = g.inbound_headers.get("X-Session-Token"),
|
||||
token_id = g.inbound_data["state"],
|
||||
token_key = g.inbound_data["state"],
|
||||
auth_token = auth_token
|
||||
)
|
||||
|
||||
|
||||
@@ -170,12 +170,13 @@ async def request_oauth_authorization_url(
|
||||
# Start by assuming failure:
|
||||
auth_url = None
|
||||
|
||||
# ┏┓ ┏┳┓ ┓ ┳ ┓
|
||||
# ┃┓┏┓┏┓┏┓┏┓┏┓╋┏┓ ┃ ┏┓┃┏┏┓┏┓ ┃┏┫
|
||||
# ┗┛┗ ┛┗┗ ┛ ┗┻┗┗ ┻ ┗┛┛┗┗ ┛┗ ┻┗┻
|
||||
# ┏┓ ┏┳┓ ┓ ┓┏┓
|
||||
# ┃┓┏┓┏┓┏┓┏┓┏┓╋┏┓ ┃ ┏┓┃┏┏┓┏┓ ┃┫ ┏┓┓┏
|
||||
# ┗┛┗ ┛┗┗ ┛ ┗┻┗┗ ┻ ┗┛┛┗┗ ┛┗ ┛┗┛┗ ┗┫
|
||||
# ┛
|
||||
|
||||
# Make a user identifier from the session info:
|
||||
token_id = await current_app.mail_controller.get_token_id(
|
||||
token_key = await current_app.mail_controller.get_token_key(
|
||||
db_conn = current_app.sql_writer,
|
||||
mongo_conn = current_app.data_mongo,
|
||||
auth_token = CoreAuthTokenModel(
|
||||
@@ -189,13 +190,12 @@ async def request_oauth_authorization_url(
|
||||
),
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
if token_id is None:
|
||||
if token_key is None:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.FAILED,
|
||||
http_code = HttpCodes.INTERNAL_SERVER_ERROR,
|
||||
message = "failed to generate token id"
|
||||
message = "failed to generate token key"
|
||||
)
|
||||
token_id = str(token_id)
|
||||
|
||||
# ┏┓ ┏┓┳┳┓ •┓
|
||||
# ┣ ┏┓┏┓ ┃┓┃┃┃┏┓┓┃
|
||||
@@ -206,7 +206,7 @@ async def request_oauth_authorization_url(
|
||||
# Get the authorization URL:
|
||||
auth_url = await current_app.gmail_client.get_authorization_url(
|
||||
scopes = SCOPES_GMAIL_MAIL_MANAGEMENT,
|
||||
state = token_id,
|
||||
state = str(token_key),
|
||||
access_type = "offline",
|
||||
approval_prompt = "force",
|
||||
include_granted_scopes = "true",
|
||||
|
||||
Reference in New Issue
Block a user