Exemple #1
0
    def __init__(
        self,
        issuer: str,
        audience: str,
        client_ids: list[str],
        scopes: Optional[dict[str, str]] = None,
        scheme_name: Optional[str] = None,
        description: Optional[str] = None,
        auto_error: Optional[bool] = True,
    ):
        # Parameters for JWT validation
        self.issuer = issuer.rstrip("/")
        self.audience = audience
        self.client_ids = client_ids

        # Flows and scopes for Swagger UI
        if not scopes:
            scopes = {}

        # Currently we only allow authorizationCode flow. Others can be added later.
        flows = OAuthFlowsModel(
            authorizationCode={
                "authorizationUrl": f"{self.issuer}/v1/authorize",
                "tokenUrl": f"{self.issuer}/v1/token",
                "refreshUrl": f"{self.issuer}/v1/token",
                "scopes": scopes,
            })
        self.model = OAuth2Model(flows=flows, description=description)
        self.scheme_name = scheme_name or self.__class__.__name__
        self.auto_error = auto_error
Exemple #2
0
 def __init__(self,
              *,
              flows: OAuthFlowsModel = OAuthFlowsModel(),
              scheme_name: str = None,
              auto_error: bool = True):
     self.model = OAuth2Model(flows=flows)
     self.scheme_name = scheme_name or self.__class__.__name__
     self.auto_error = auto_error
Exemple #3
0
 def __init__(self,
              *,
              flows: Union[OAuthFlowsModel,
                           Dict[str, Dict[str, Any]]] = OAuthFlowsModel(),
              scheme_name: Optional[str] = None,
              auto_error: Optional[bool] = True):
     self.model = OAuth2Model(flows=flows)
     self.scheme_name = scheme_name or self.__class__.__name__
     self.auto_error = auto_error
Exemple #4
0
    def __init__(
        self,
        authorizationUrl: str,
        tokenUrl: str,
        handler: MSALAuthCodeHandler,
        refreshUrl: Optional[str] = None,
        scopes: Optional[Dict[str, str]] = None,
    ):
        self.handler = handler
        if not scopes:
            scopes = {}
        self.scheme_name = self.__class__.__name__

        flows = OAuthFlowsModel(
            authorizationCode=OAuthFlowAuthorizationCode(
                authorizationUrl=authorizationUrl,
                tokenUrl=tokenUrl,
                scopes=scopes,
                refreshUrl=refreshUrl,
            )
        )
        # needs further investigation (type...)
        self.model = OAuth2Model(flows=flows, type=SecuritySchemeType.oauth2)
Exemple #5
0
 def __init__(self,
              *,
              flows: OAuthFlowsModel = OAuthFlowsModel(),
              scheme_name: str = None):
     self.model = OAuth2Model(flows=flows)
     self.scheme_name = scheme_name or self.__class__.__name__