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

feat: Allow user agent to be modified #98

Merged
merged 1 commit into from
Mar 16, 2018
Merged

Conversation

robertjd
Copy link
Contributor

@robertjd robertjd commented Mar 13, 2018

This allows other libraries to prefix the user agent, rather than overwriting it entirely with passed options.

Part of resolving OKTA-158252

robertjd pushed a commit to okta/okta-oidc-js that referenced this pull request Mar 13, 2018
@@ -56,6 +56,8 @@ function OktaAuthBuilder(args) {
headers: args.headers
};

this.userAgent = 'okta-auth-js-' + config.SDK_VERSION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of assigning it here, would it make sense to push this over to our config object?

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why we're making this an accessible property as opposed to concatenating the passed user agent during object construction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While our current use case is concatenation to achieve a prepend, I don't want to limit us to that behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this implementation force user-agent overrides though? Someone can rewrite our custom user agents by forgetting to append the authJS.userAgent value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already possible to overwrite the entire user agent with this construction:

new OktaAuth({
  headers: {
    'X-Okta-User-Agent': 'foo'
  }
});

What we need is a way for this library to expose what it's "default" user agent is, so that the consuming library can include that default user agent in it's intended re-write of the user agent. That's what this PR attempts to do. Enforcing a default user agent substring is out of scope, and IMO a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. 👍

robertjd pushed a commit to okta/okta-oidc-js that referenced this pull request Mar 16, 2018
This allows other libraries to prefix the user agent, rather than overwriting it entirely with passed options
@robertdamphousse-okta robertdamphousse-okta merged commit 77c3839 into master Mar 16, 2018
@robertdamphousse-okta robertdamphousse-okta deleted the rd-user-agent branch March 16, 2018 21:02
robertjd pushed a commit to okta/okta-oidc-js that referenced this pull request Mar 16, 2018
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.

3 participants