File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 4545 oauth2_scheme = OAuth2PasswordBearer (tokenUrl = "auth/token" )
4646else :
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" )
5249pwd_context = CryptContext (schemes = ["bcrypt" ], deprecated = "auto" )
5350
5451instrument_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 ,
You can’t perform that action at this time.
0 commit comments