2020-02-04 13:54:53 +00:00
|
|
|
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,
|
2020-02-04 13:54:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def create(self, scheme):
|
2021-04-23 11:36:27 +00:00
|
|
|
scheme_type = scheme['type']
|
|
|
|
if scheme_type == 'apiKey':
|
2020-02-04 13:54:53 +00:00
|
|
|
return ApiKeyProvider(scheme)
|
2021-04-23 11:36:27 +00:00
|
|
|
elif scheme_type == 'http':
|
2020-02-04 13:54:53 +00:00
|
|
|
return HttpProvider(scheme)
|
|
|
|
return UnsupportedProvider(scheme)
|