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

Connect to a DB by directly supplying access token #26

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

RudraNirvan
Copy link

Refer to the example file (examples/azuread-service-principal-authtoken/service_principal_authtoken.go) to understand how it will work.

EOL CRLF difference is causing all the lines to be shown as changed, not sure if GitHub offers an option to ignore this while reviewing, suggestions are welcome.

Fixes #24.

@ghost
Copy link

ghost commented May 21, 2022

CLA assistant check
All CLA requirements met.

@shueybubbles
Copy link
Collaborator

I think this scenario was supposed to be covered by the non-AAD-aware token provider interface here:

func NewSecurityTokenConnector(config msdsn.Config, tokenProvider func(ctx context.Context) (string, error)) (*Connector, error) {

No need to bring in any azuread dependencies, just provide a function that provides the token

@RudraNirvan
Copy link
Author

RudraNirvan commented May 21, 2022

@shueybubbles yes, but how will a client of this library use it? This PR allows one to easily supply the token as a part of the connection string when connecting to the DB. Internally, you will notice that I am using the same NewSecurityTokenConnector.

Refer to the connection string in the example file: "server=%s;password=%s;port=%d;database=%s;fedauth=ActiveDirectoryServicePrincipalAccessToken;"

That's it, one will now only need to supply the access token as the password.

@RudraNirvan
Copy link
Author

RudraNirvan commented May 21, 2022

@shueybubbles For the access token to work, it needs to pass through the fedauth login workflow. Refer:

case fe.FedAuthLibrary == FedAuthLibrarySecurityToken:

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@1598eaf). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #26   +/-   ##
=======================================
  Coverage        ?   71.19%           
=======================================
  Files           ?       24           
  Lines           ?     5427           
  Branches        ?        0           
=======================================
  Hits            ?     3864           
  Misses          ?     1319           
  Partials        ?      244           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1598eaf...91766b9. Read the comment docs.

@shueybubbles shueybubbles merged commit f6444fb into microsoft:main Jun 16, 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.

AAD authentication by providing access token
3 participants