feat: don't rely on secure JWT when it comes to scopes
This commit is contained in:
		@@ -141,8 +141,9 @@ async def get_current_user(
 | 
				
			|||||||
    user = get_user(username=token_data.username)
 | 
					    user = get_user(username=token_data.username)
 | 
				
			||||||
    if user is None:
 | 
					    if user is None:
 | 
				
			||||||
        raise credentials_exception
 | 
					        raise credentials_exception
 | 
				
			||||||
 | 
					    allowed_scopes = set(user.scopes.split())
 | 
				
			||||||
    for scope in security_scopes.scopes:
 | 
					    for scope in security_scopes.scopes:
 | 
				
			||||||
        if scope not in token_data.scopes:
 | 
					        if scope not in allowed_scopes or scope not in token_data.scopes:
 | 
				
			||||||
            raise HTTPException(
 | 
					            raise HTTPException(
 | 
				
			||||||
                status_code=status.HTTP_401_UNAUTHORIZED,
 | 
					                status_code=status.HTTP_401_UNAUTHORIZED,
 | 
				
			||||||
                detail="Not enough permissions",
 | 
					                detail="Not enough permissions",
 | 
				
			||||||
@@ -159,6 +160,10 @@ async def get_current_active_user(
 | 
				
			|||||||
    return current_user
 | 
					    return current_user
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async def verify_team_scope(user: Annotated[Player, Depends(get_current_active_user)]):
 | 
				
			||||||
 | 
					    allowed_scopes = set(user.scopes.split())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def login_for_access_token(
 | 
					async def login_for_access_token(
 | 
				
			||||||
    form_data: Annotated[OAuth2PasswordRequestForm, Depends()], response: Response
 | 
					    form_data: Annotated[OAuth2PasswordRequestForm, Depends()], response: Response
 | 
				
			||||||
) -> Token:
 | 
					) -> Token:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user