Skip to content
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

Add ability to authenticate through the use of a bearer token #84

Merged
merged 4 commits into from
Jun 10, 2022

Conversation

InsomniaDev
Copy link
Collaborator

No description provided.

@InsomniaDev InsomniaDev requested a review from riferrei June 8, 2022 20:51
@InsomniaDev InsomniaDev linked an issue Jun 9, 2022 that may be closed by this pull request
@InsomniaDev InsomniaDev self-assigned this Jun 9, 2022
@riferrei
Copy link
Owner

riferrei commented Jun 9, 2022

Hi @InsomniaDev. I did review your PR, and if you don't mind, could you please implement the following changes:

  1. Move the bearer token from SchemaRegistryClient struct to the credentials struct.
  2. Change the function SetBearerToken to write is data to the internal credentials struct.
  3. Adjust the function httpRequest to include a logic like the below:
	if client.credentials != nil {
                 if len(client.credentials.username) > 0 && len(client.credentials.password) > 0 {
                       req.SetBasicAuth(client.credentials.username, client.credentials.password)
                 } else if len(client.credentials.bearerToken) > 0 {
                       req.Header.Add("Authorization", "Bearer "+client.credentials.bearerToken)
                 }
	}
  1. Fix the mocks accordingly. 🙂

I think this way improves the code's readability.

Thanks,

@riferrei

@InsomniaDev
Copy link
Collaborator Author

@riferrei - updated and also added comments in the code to aid with readability.

@riferrei riferrei merged commit bfdfd5e into master Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bearer Authentication Missing
2 participants