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

v11.0.0 #326

Merged
merged 2 commits into from
Sep 29, 2018
Merged

v11.0.0 #326

merged 2 commits into from
Sep 29, 2018

Conversation

jhendrixMSFT
Copy link
Member

@jhendrixMSFT jhendrixMSFT commented Sep 28, 2018

Changed a few fields in adal.Token from string to json.Number to handle
differences between AAD and ADFS in how they send data over the wire.
Added auth.NewAuthorizerFromFileWithResource to create an authorizer
from the config file with the specified resource.
Setting a client's PollingDuration to zero will use the provided context
to control a LRO's polling duration.

Thank you for your contribution to Go-AutoRest! We will triage and review it as soon as we can.

As part of submitting, please make sure you can make the following assertions:

  • I've tested my changes, adding unit tests if applicable.
  • I've added Apache 2.0 Headers to the top of any new source files.
  • I'm submitting this PR to the dev branch, except in the case of urgent bug fixes warranting their own release.
  • If I'm targeting master, I've updated CHANGELOG.md to address the changes I'm making.

@jhendrixMSFT
Copy link
Member Author

Fixes #325

ExpiresIn string `json:"expires_in"`
ExpiresOn string `json:"expires_on"`
NotBefore string `json:"not_before"`
ExpiresIn json.Number `json:"expires_in"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good moment to add some documentation about the expected contents of these values as well.

For example, I believe this is a whole number of seconds. We should say so :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a link to the docs for this type.

@@ -868,7 +862,7 @@ func expireToken(t *Token) *Token {

func setTokenToExpireAt(t *Token, expireAt time.Time) *Token {
t.ExpiresIn = "3600"
t.ExpiresOn = strconv.Itoa(int(expireAt.Sub(date.UnixEpoch()).Seconds()))
t.ExpiresOn = json.Number(strconv.Itoa(int(expireAt.Sub(date.UnixEpoch()).Seconds())))
Copy link
Member

@marstr marstr Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this to

t.ExpiresOn = json.Number(fmt.Sprintf(int64(expireAt.Sub(date.UnixEpoch()) / time.Second)))

While it's not any more readable, it has two advantages IMHO:

  1. Not calling .Seconds() prevents the conversion from an int type to a float type.
  2. Using fmt.Sprintf() instead of strconv.Itoa() prevents us from casting down from 64 bits to 32 bits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errr, I see this is just a test file so don't see this comment as too blocking or anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweaked this a bit.

Changed a few fields in adal.Token from string to json.Number to handle
differences between AAD and ADFS in how they send data over the wire.
Added auth.NewAuthorizerFromFileWithResource to create an authorizer
from the config file with the specified resource.
Setting a client's PollingDuration to zero will use the provided context
to control a LRO's polling duration.
@jhendrixMSFT jhendrixMSFT changed the title Fixes in adal.Token for ADFS v11.0.0 Sep 28, 2018
@jhendrixMSFT
Copy link
Member Author

Fixes #314

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.

2 participants