-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract authentication flow into new interface #20
Conversation
ceac461
to
d122bf9
Compare
715fc6e
to
2b2566d
Compare
b3d4298
to
370bb5b
Compare
370bb5b
to
3c5b1ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
""" | ||
|
||
@abc.abstractmethod | ||
async def authenticate(self, api_key: str, ssl_verification_data: SslVerificationMetadata) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something on the authenticate signature on this interface. Not all authenticators use the api_key
parameter. I think they each have their own set of parameters required to carry out authentication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give me an example of an authenticator that doesn't use an api key? If you're referring to the JWT or GCP authenticators, they still have a string value that takes the place of an api_token. Maybe we can call this something else to make it more general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree w/ @doodlesbykumbi. Only the default authenticator uses the API key. All other authenticators validate the external identity and return a Conjur Auth token.
What about injecting the strategy along the lines of:
credentials = CredentialsData(username=username, password=password, machine=conjur_url)
credentials_provider = SimpleCredentialsProvider()
credentials_provider.save(credentials)
del credentials
client = Client(connection_info,
authentication_strategy=Authn(credentials_provider=credentials_provider)
ssl_verification_mode=ssl_verification_mode)
client = Client(connection_info,
authentication_strategy=AuthnLdap(credentials_provider=credentials_provider)
ssl_verification_mode=ssl_verification_mode)
client = Client(connection_info,
authentication_strategy=AuthnJwt(jwt='path-to-jwt')
ssl_verification_mode=ssl_verification_mode)
If the Authentication Strategy interface includes a method (maybe authenticate
), and returns a Conjur Auth Token, we can inject the "how" into our client.
self._account = account | ||
self._login_id = login_id | ||
|
||
async def authenticate(self, api_key: str, ssl_verification_data) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, having this method take CredentialsData
via a SimpleCredentialsProvider
allows the authentication to be handled here.
As a note, we may need to add a second/alternative CredentialsData
type to handle hostname/api key. Users exchange a username/password for an api key, then authenticate with the username/api key combination. Hosts authenticate with host/<hostname>
/api key combination (note the host
in front of the hostname).
766b11e
to
1e6432b
Compare
15bacd1
to
89ac4c1
Compare
89ac4c1
to
deb6615
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, if there are remaining items from Jason or Kumbi they can be addressed in a follow up so this can move forward.
Note: To see implementation in the CLI, see cyberark/cyberark-conjur-cli#410
Desired Outcome
Create a new
AuthenticationStrategy
interface that will allow us to abstract the authentication flow. The interface shouldtake a
CredentialProvider
and Conjur account as inputs, as well as any other arguments that are needed to authenticate,such as
service_id
for LDAP. The interface should have aauthenticate
method which returns a Conjur auth token. All details of authentication should be handled by theAuthenticationStrategy
interface.Include unit tests and update existing unit and integration tests.
Implemented Changes
AuthenticationStrategyInterface
to abstract authentication logicAuthnAuthenticationStrategy
which implements the interface for the default authn strategyConnected Issue/Story
CyberArk internal issue link: ONYX-20429
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
README
s) were updated in this PRBehavior
Security