Skip to content

Commit

Permalink
Handle root URL's with trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Bourne authored and crewjam committed May 1, 2019
1 parent 2076e45 commit 724cb1c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions samlsp/samlsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ type Options struct {

// New creates a new Middleware
func New(opts Options) (*Middleware, error) {
metadataURL := opts.URL
metadataURL.Path = metadataURL.Path + "/saml/metadata"
acsURL := opts.URL
acsURL.Path = acsURL.Path + "/saml/acs"
metadataRelURL, _ := url.Parse("saml/metadata")
metadataURL := opts.URL.ResolveReference(metadataRelURL)
acsRelURL, _ := url.Parse("saml/acs")
acsURL := opts.URL.ResolveReference(acsRelURL)
logr := opts.Logger
if logr == nil {
logr = logger.DefaultLogger
Expand All @@ -56,8 +56,8 @@ func New(opts Options) (*Middleware, error) {
Key: opts.Key,
Logger: logr,
Certificate: opts.Certificate,
MetadataURL: metadataURL,
AcsURL: acsURL,
MetadataURL: *metadataURL,
AcsURL: *acsURL,
IDPMetadata: opts.IDPMetadata,
ForceAuthn: &opts.ForceAuthn,
},
Expand Down

3 comments on commit 724cb1c

@evt
Copy link

@evt evt commented on 724cb1c Nov 11, 2019

Choose a reason for hiding this comment

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

We have an issue after this change with opts.URL having some path. For example:

http://www.some.site/path + saml/acs should be http://www.some.site/path/saml/acs after ResolveReference but it's not as per the following example - https://play.golang.org/p/Uq0jFjdGrAJ

Do you want me to make PR to fix it?

@crewjam
Copy link
Owner

Choose a reason for hiding this comment

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

Yes please, that would be great. Thanks!

@evt
Copy link

@evt evt commented on 724cb1c Nov 11, 2019

Choose a reason for hiding this comment

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

Actually it seems working correct if you add a slash after path in opts.URL - https://play.golang.org/p/hO5nNhovsAK - so, no fix needed, thank you! :)

Please sign in to comment.