Skip to content

Commit aaefe64

Browse files
committed
Rewrote 'oauth2_scheme' and 'instrument_oauth2_scheme' variables as inline if-else statements instead
1 parent 7f4ca87 commit aaefe64

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/murfey/server/api/auth.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
auth_url = security_config.auth_url
4040
ALGORITHM = security_config.auth_algorithm or "HS256"
4141
SECRET_KEY = security_config.auth_key or secrets.token_hex(32)
42-
if security_config.auth_type == "password":
43-
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")
44-
else:
45-
oauth2_scheme = APIKeyCookie(name=security_config.cookie_key)
46-
if security_config.instrument_auth_type == "token":
47-
instrument_oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")
48-
else:
49-
instrument_oauth2_scheme = lambda *args, **kwargs: None
42+
oauth2_scheme = (
43+
OAuth2PasswordBearer(tokenUrl="auth/token")
44+
if security_config.auth_type == "password"
45+
else APIKeyCookie(name=security_config.cookie_key)
46+
)
47+
instrument_oauth2_scheme = (
48+
OAuth2PasswordBearer(tokenUrl="auth/token")
49+
if security_config.instrument_auth_type == "token"
50+
else lambda *args, **kwargs: None
51+
)
5052
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
5153

5254
instrument_server_tokens: dict[float, dict] = {}

0 commit comments

Comments
 (0)