Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

fix #1155 by renaming signalRTokenHeader to access_token #1343

Merged
merged 2 commits into from
Jan 26, 2018

Conversation

analogrelay
Copy link
Contributor

I actually started this on release/2.1 because to be honest, it's pretty simple and I feel comfortable taking it in preview 1 if @muratg is OK with that. It's low-hanging fruit, and it's "public" API surface (kinda) so front-loading it would be nice. Also, I was reviewing the OAuth spec and noticed that it calls out how to pass access tokens via the query string in the spec (https://tools.ietf.org/html/rfc6750#section-2.3), including the query string name to use, access_token (as @PinpointTownes referenced in the issue #1155).

Browser functional tests have been updated and run (next up on my plate is to automate those ;)). JwtSample has also been updated and verified. The C# client doesn't ever use the query string, so the only product changes are in the Jwt sample (since we haven't decided what to "build in" for this yet) and the TS client.

Anyway, this PR is on dev right now. If @muratg signs off on pulling it up to preview 1, I'll retarget to release/2.1

@analogrelay analogrelay changed the title rename signalRTokenHeader to access_token fix #1155 by renaming signalRTokenHeader to access_token Jan 25, 2018
Copy link

@muratg muratg left a comment

Choose a reason for hiding this comment

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

Approved for Preview1 check-in. (Pending proper code review. :) )

@@ -68,9 +68,9 @@ export class HttpConnection implements IConnection {
}
else {
let headers;
if (this.options.accessToken) {
if (this.options.accessTokenFactory) {

Choose a reason for hiding this comment

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

Curious: is accessTokenFactory allowed to return a null/empty token? Should a non-null token check be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it could, and I don't see why we couldn't "allow" it (and just not provide the header).

url += (url.indexOf("?") < 0 ? "?" : "&") + `signalRTokenHeader=${token}`;
if (this.accessTokenFactory) {
let token = this.accessTokenFactory();
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${token}`;

Choose a reason for hiding this comment

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

Same question (also, should you URLencode the token query string parameter, just in case?)

@kevinchalet
Copy link

Thanks for fixing that 👍

@analogrelay analogrelay changed the base branch from dev to release/2.1 January 25, 2018 01:02
@analogrelay
Copy link
Contributor Author

Base changed to release/2.1, feedback addressed. Functional Tests actually weren't quite working, fixed that now. Also verified the JwtSample and Functional Tests with the latest version, after addressing feedback.

@analogrelay
Copy link
Contributor Author

analogrelay commented Jan 25, 2018

FYI I addressed @PinpointTownes 's comment about the factory returning null by changing the logic a little. The constructors that accept the factories now ensure they are always non-null by using a "default" factory that returns null all the time if the factory itself is null. Then the logic just shifts to only writing the header/qs if the factory returns a truthy value (rather than testing if the factory is present).

@mikaelm12
Copy link
Contributor

Yeah, until we get some automation running, the first comment for any typescript changes should be have you run the browser tests

options = options || {};
options.accessTokenFactory = options.accessTokenFactory || (() => null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be easier to just do a null check on the accessTokenFactory before creating and checking the token. It gets rid of some of the logic

Copy link
Contributor

Choose a reason for hiding this comment

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

In a couple of places

@davidfowl
Copy link
Member

Looks mechanical

@muratg muratg added this to the 2.1.0-preview1 milestone Jan 25, 2018
Copy link

@muratg muratg left a comment

Choose a reason for hiding this comment

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

Approved for preview1.

@analogrelay analogrelay force-pushed the anurse/1155-accesstoken-rename branch from 7ad49b5 to 22dc794 Compare January 25, 2018 18:19
@analogrelay
Copy link
Contributor Author

Rebased so Travis and AppVeyor could see it. Merging when I get some green.

@analogrelay analogrelay merged commit 6590992 into release/2.1 Jan 26, 2018
@analogrelay analogrelay deleted the anurse/1155-accesstoken-rename branch January 30, 2018 20:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants