openapi-core/openapi_core/security/factories.py

21 lines
572 B
Python
Raw Normal View History

from openapi_core.schema.security_schemes.enums import SecuritySchemeType
from openapi_core.security.providers import (
ApiKeyProvider, HttpProvider, UnsupportedProvider,
)
class SecurityProviderFactory(object):
PROVIDERS = {
2021-04-23 11:36:27 +00:00
'apiKey': ApiKeyProvider,
'http': HttpProvider,
}
def create(self, scheme):
2021-04-23 11:36:27 +00:00
scheme_type = scheme['type']
if scheme_type == 'apiKey':
return ApiKeyProvider(scheme)
2021-04-23 11:36:27 +00:00
elif scheme_type == 'http':
return HttpProvider(scheme)
return UnsupportedProvider(scheme)