-
Notifications
You must be signed in to change notification settings - Fork 76
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
Enable usage of bearer tokens #341
Conversation
Add support for bearer token
* The default token is now a bearer token * The library accepts both authorization and bearer tokens when passed as user option
@@ -79,7 +79,7 @@ var ( | |||
LogHttpResponse bool = true | |||
|
|||
// List of tags to be excluded from logging | |||
skipTags = []string{"SupportedVersions", "ovf:License"} | |||
skipTags = []string{"ovf:License"} |
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.
the SupportedVersions call in recent releases has become short and bearable, while up to 9.5 it was 600+ lines.
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.
Maybe we already can update sample configuration and state that
# The vCD address, in the format https://vCD_IP/api
# or https://vCD_host_name/api
url: https://11.111.1.111/api
should be
url: https://11.111.1.111/openapi
Not yet.
|
If a VCD has disabled authentication using /api/sessions we can automatically attempt a connection using /cloudapi/1.0.0/sessions
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.
My testing worked out well.
CHANGELOG.md
Outdated
* Added methods `adminVdc.UpdateStorageProfile` [#340](https://github.com/vmware/go-vcloud-director/pull/340) | ||
|
||
BREAKING CHANGES: | ||
|
||
* type.VdcConfiguration (used for creation) changed the type for storage profile from `[]*VdcStorageProfile` to `[]*VdcStorageProfileConfiguration` | ||
>>>>>>> master |
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.
Leftover
vcdCli.Client.VCDToken = resp.Header.Get(AuthorizationHeader) | ||
vcdCli.Client.VCDAuthHeader = AuthorizationHeader | ||
vcdCli.Client.VCDToken = resp.Header.Get(BearerTokenHeader) | ||
vcdCli.Client.VCDAuthHeader = BearerTokenHeader |
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'm a bit confused by this part. Have we removed the authorization token completely in favor of the bearer token?
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.
No.
We have changed the token that we use to keep the client working. Previously, we injected the authorization token at connection time in the client, so that it would be used for further operations. Now we use the bearer token for the same purpose.
However, if you connect using the old authorization token, it will be used like before.
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!
The SDK now accepts both the old (deprecated) authorization token and the bearer token.
The usage is transparent: it doesn't require new options or configuration. If we enter a bearer token instead of an authorization token, it gets used.
How to test:
./scripts/get_token.sh
GOVCD_LOG_PASSWORDS=1
Test_GetVcdVersion
)Authorization
header now contains the bearer token and that theX-Vmware-Vcloud-Token-Type
header contains "Bearer".Authorization
header contains the bearer token.This PR also adds a transparent fallback connection using
cloudapi/1.0.0/sessions
when the call to/api/session
has been disabled. No action is needed to activate it. When the fallback call happens, we'll find trace information in the logs:To test the fallback functionality, disable access to
api/sessions
following the instructions in this page and then run any test without token.