Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: add configurable redirect_url, preserve default value #229

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

lgarrett-isp
Copy link
Collaborator

@lgarrett-isp lgarrett-isp commented Dec 6, 2023

This enables users to configure a specific hostname for the auth_code callback. When not configured, the existing value ("http://localhost:8484") is used.

I chose to make this a "top-level" param given that it's listed in https://www.oauth.com/oauth2-servers/pkce/, but I would be happy to use the custom-params support instead if preferred.

@@ -234,8 +243,12 @@ func (ac *AuthorizationCodeTokenSource) Token() (*oauth2.Token, error) {
c: codeChan,
}

// strip protocol prefix from configured redirect url for local webserver
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm noodling on whether it would be better to do something like

u, _ := url.Parse(ac.getRedirectUrl())
redirectServer := fmt.Sprintf("%s:%d", u.Hostname(), u.Port())

Any thoughts?

Copy link
Owner

Choose a reason for hiding this comment

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

That's probably better than the trim calls. I do wonder though if we should be using the configured hostname or always use localhost instead... like what if the hostname doesn't resolve to localhost? 🤔 I suppose it doesn't matter for our use-case so could always be modified later.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Merging #229 (9a25266) into main (b75a307) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #229   +/-   ##
=======================================
  Coverage   76.92%   76.92%           
=======================================
  Files          26       26           
  Lines        3666     3666           
=======================================
  Hits         2820     2820           
  Misses        639      639           
  Partials      207      207           

Continue to review full report in Codecov by Sentry.

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

@lgarrett-isp lgarrett-isp merged commit a92c7db into main Dec 6, 2023
6 checks passed
@lgarrett-isp lgarrett-isp deleted the redirect-url branch December 6, 2023 23:37
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants