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