mirror of
https://github.com/correl/openapi-core.git
synced 2024-12-29 11:09:25 +00:00
19 lines
605 B
Python
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)
|