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

Add support for oauth2 beind proxy #730

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

KnisterPeter
Copy link
Contributor

This change does use the public_url config value to create the oauth2 callback url. This logic is only setup
if the config value has been set.

Closes #724

This change does use the public_url config value to create
the oauth2 callback url. This logic is only setup
if the config value has been set.

Closes palantir#724
@palantirtech
Copy link
Member

Thanks for your interest in palantir/policy-bot, @KnisterPeter! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

Copy link
Member

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

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

Thanks! I had two minor suggestions that should simplify this.

server/server.go Outdated
oauth2.OnLogin(handler.Login(c.Github, basePath, sessions)),
}
if c.Server.PublicURL != "" {
u, err := url.Parse(c.Server.PublicURL)
Copy link
Member

Choose a reason for hiding this comment

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

This is already parsed as publicURL on L73, so I think you can re-use it here. Since the earlier logic also requires that the value is not empty, I think we can unconditionally set the WithRedirectURL parameter.

server/server.go Outdated
@@ -218,17 +218,29 @@ func New(c *Config) (*Server, error) {
Base: basePolicyHandler,
}

oauth2Params := []oauth2.Param{
oauth2.ForceTLS(forceTLS),
Copy link
Member

Choose a reason for hiding this comment

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

The ForceTLS option is only used to generate URLs, so we should be able to remove it now that we're setting a fixed URL.

@KnisterPeter
Copy link
Contributor Author

@bluekeyes That's indeed much cleaner 😃

@bluekeyes bluekeyes merged commit 81cfd92 into palantir:develop Mar 18, 2024
7 checks passed
@fordneild
Copy link

It seems to me that this prohibits hosting policy-bot at a non root url, such as my-domain.com/policy-bot/ since my path is getting wiped by the default one. Am i missing something?

@bluekeyes
Copy link
Member

@fordneild good point, I think that was an oversight here - the public_url value should be allowed to contain subpaths and the OAuth routes should be added to those paths. I filed #804 to track this.

@fordneild
Copy link

Thanks for the quick fix!

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.

Unable to run policy-bot behind a reverse-prxoy
4 participants