openapi-core/openapi_core/security/factories.py
2020-02-04 13:58:42 +00:00

19 lines
605 B
Python

from openapi_core.schema.security_schemes.enums import SecuritySchemeType
from openapi_core.security.providers import (
ApiKeyProvider, HttpProvider, UnsupportedProvider,
)
class SecurityProviderFactory(object):
PROVIDERS = {
SecuritySchemeType.API_KEY: ApiKeyProvider,
SecuritySchemeType.HTTP: HttpProvider,
}
def create(self, scheme):
if scheme.type == SecuritySchemeType.API_KEY:
return ApiKeyProvider(scheme)
elif scheme.type == SecuritySchemeType.HTTP:
return HttpProvider(scheme)
return UnsupportedProvider(scheme)