Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Add get_current_user function to oauth_util.py #27

@sanders41

Description

@sanders41

Is your feature request related to a specific problem?

oauth_util.py should have a get_current_user function

A description of what the problem is.
Ex. I'm always frustrated when [...]

Describe the solution you'd like

from fastapi import Depends, Security
from fastapi.security import SecurityScopes
from sqlalchemy.orm import Session

from fideslib.oauth.api.deps import get_db
from fideslib.models.fides_user import FidesUser

async def get_current_user(
    security_scopes: SecurityScopes,
    authorization: str = Security(oauth2_scheme),
    db: Session = Depends(get_db),
) -> FidesUser:
    """A wrapper around verify_oauth_client that returns that client's user if one exsits."""
    client = await verify_oauth_client(
        security_scopes=security_scopes,
        authorization=authorization,
        db=db,
    )
    return client.user

Describe alternatives you've considered, if any

Let each library implement their own version.

Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions