Skip to content

Commit bd2ee0d

Browse files
committed
Header for web3 application id usage naming
1 parent 21013e7 commit bd2ee0d

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

brood/middleware.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22
import json
33
import logging
4-
from typing import cast, Optional
4+
from typing import Optional, cast
55
from uuid import UUID
66

77
from fastapi import Depends, HTTPException, Request
@@ -20,7 +20,7 @@
2020
from .settings import (
2121
BOT_INSTALLATION_TOKEN,
2222
BOT_INSTALLATION_TOKEN_HEADER,
23-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER,
23+
BUGOUT_APPLICATION_ID_HEADER,
2424
)
2525

2626
logger = logging.getLogger(__name__)
@@ -45,9 +45,7 @@ async def get_current_user(
4545
if token is None or token == "":
4646
raise HTTPException(status_code=404, detail="Access token not found")
4747

48-
signature_application: str = request.headers.get(
49-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER
50-
)
48+
signature_application: str = request.headers.get(BUGOUT_APPLICATION_ID_HEADER)
5149
application_id = None
5250
if signature_application is not None:
5351
try:
@@ -143,9 +141,7 @@ async def get_current_user_with_groups(
143141
if token is None or token == "":
144142
raise HTTPException(status_code=404, detail="Access token not found")
145143

146-
signature_application: str = request.headers.get(
147-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER
148-
)
144+
signature_application: str = request.headers.get(BUGOUT_APPLICATION_ID_HEADER)
149145
application_id = None
150146
if signature_application is not None:
151147
try:

brood/settings.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,8 @@ def group_invite_link_from_env(code: str, email: Optional[str] = None) -> str:
9898
BROOD_OPENAPI_LIST = BROOD_OPENAPI_LIST_RAW.split(",")
9999

100100
# Web3 signature
101-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER_RAW = os.environ.get(
102-
"BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER"
103-
)
104-
if BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER_RAW is not None:
105-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER = (
106-
BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER_RAW
107-
)
101+
BUGOUT_APPLICATION_ID_HEADER_RAW = os.environ.get("BUGOUT_APPLICATION_ID_HEADER")
102+
if BUGOUT_APPLICATION_ID_HEADER_RAW is not None:
103+
BUGOUT_APPLICATION_ID_HEADER = BUGOUT_APPLICATION_ID_HEADER_RAW
108104
else:
109-
raise ValueError(
110-
"BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER environment variable must be set"
111-
)
105+
raise ValueError("BUGOUT_APPLICATION_ID_HEADER environment variable must be set")

configs/sample.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export BUGOUT_BOT_INSTALLATION_TOKEN="<token_for_autogenerated_users>"
1414
export BUGOUT_BOT_INSTALLATION_TOKEN_HEADER="<bugout_installation_token_header>"
1515

1616
# Web3 signature variables
17-
export BUGOUT_WEB3_SIGNATURE_APPLICATION_HEADER="x-bugout-web3-signature-application"
17+
export BUGOUT_APPLICATION_ID_HEADER="x-bugout-application-id"
1818

1919
# Set the following variables in the most reasonable manner for your development environment
2020
export STRIPE_SECRET_KEY="<Stripe_API_secret_key>"

0 commit comments

Comments
 (0)