Skip to content

Commit 15cceb9

Browse files
committed
if instrument server auth type is not set to token skip validation of the instrument token
1 parent 26fad3b commit 15cceb9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/murfey/server/api/auth.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@
4545
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")
4646
else:
4747
oauth2_scheme = APIKeyCookie(name=security_config.cookie_key)
48-
if security_config.instrument_auth_type == "token":
49-
instrument_oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")
50-
else:
51-
instrument_oauth2_scheme = lambda *args, **kwargs: None
48+
instrument_oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token")
5249
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
5350

5451
instrument_server_tokens: Dict[float, dict] = {}
@@ -169,7 +166,7 @@ async def validate_instrument_token(
169166
validation_outcome = await response.json()
170167
if not (success and validation_outcome.get("valid")):
171168
raise JWTError
172-
else:
169+
elif security_config.instrument_auth_type == "token":
173170
# First, check if the token has expired
174171
decoded_data = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
175172
if expiry_time := decoded_data.get("expiry_time"):
@@ -187,6 +184,8 @@ async def validate_instrument_token(
187184
raise JWTError
188185
else:
189186
raise JWTError
187+
else:
188+
return None
190189
except JWTError:
191190
raise HTTPException(
192191
status_code=status.HTTP_401_UNAUTHORIZED,

0 commit comments

Comments
 (0)