-
Notifications
You must be signed in to change notification settings - Fork 40
Description
We already have RequestAuthenticationInterface, with ApiKeyRequestAuthentication currently being the only implementation of that interface.
Since pretty much all cloud providers today require an API key for authentication, we don't need to expand the available implementations just yet.
However, what we should do is to properly set up an association between each provider and which authentication method they use. Today, all our code can simply just assume that a cloud provider needs an API key, which is not a proper solution.
Implementing this should be pretty straightforward. Authentication classes can already provide context about its necessary input, via the getJsonSchema() method. They can also be dynamically instantiated without coupling things to a concrete constructor, via the fromArray() method.
Proposed approach
- Add a new optional
authenticationMethodfield / key toProviderMetadata, which will contain an identifier of an available authentication method.- For now, the only possible values will be
NONEandAPI_KEY. - As reasonable defaults, use
API_KEYif the provider type isCLOUD, and useNONEotherwise. - That being said, we should still update all provider implementations to explicitly set those values, as a good example.
- For now, the only possible values will be
- Add a way to get the authentication class for a given authentication identifier.
- Either use an enum class, with a custom additional method to get the class name associated with the identifier.
- Or implement an authentication registry where authentication classes can be registered with an identifier.
- The latter is probably the proper long-term solution, but we could start with the former to keep things simple for now. It could be iterated on later without breaking changes.
- Update
ProviderRegistry::setRequestAuthenticationForProviderto include a check in the beginning to ensure the given authentication instance is of the class expected by the provider. If not, throw an exception. - Update
ProviderRegistry::createDefaultProviderRequestAuthenticationto look up which class is needed, instead of havingApiKeyRequestAuthenticationhard-coded.