Skip to content

Commit

Permalink
fix: login and consent redirect behavior change since 1.9.x (ory#2457)
Browse files Browse the repository at this point in the history
Allow #fragment in configured url to keep backwards compatibility.

Close ory#2363

Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com>
  • Loading branch information
2 people authored and mitar committed May 13, 2021
1 parent 88482e6 commit 3e3efbd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions driver/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ func (p *Provider) fallbackURL(path string, host string, port int) *url.URL {
}

func (p *Provider) LoginURL() *url.URL {
return urlRoot(p.p.RequestURIF(KeyLoginURL, p.publicFallbackURL("oauth2/fallbacks/login")))
return urlRoot(p.p.URIF(KeyLoginURL, p.publicFallbackURL("oauth2/fallbacks/login")))
}

func (p *Provider) LogoutURL() *url.URL {
return urlRoot(p.p.RequestURIF(KeyLogoutURL, p.publicFallbackURL("oauth2/fallbacks/logout")))
}

func (p *Provider) ConsentURL() *url.URL {
return urlRoot(p.p.RequestURIF(KeyConsentURL, p.publicFallbackURL("oauth2/fallbacks/consent")))
return urlRoot(p.p.URIF(KeyConsentURL, p.publicFallbackURL("oauth2/fallbacks/consent")))
}

func (p *Provider) ErrorURL() *url.URL {
Expand Down
40 changes: 40 additions & 0 deletions driver/config/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,43 @@ func TestViperProviderValidates(t *testing.T) {
},
}, c.Tracing())
}

func TestSetPerm(t *testing.T) {
f, e := ioutil.TempFile("", "test")
require.NoError(t, e)
path := f.Name()

// We cannot test setting owner and group, because we don't know what the
// tester has access to.
_ = (&configx.UnixPermission{
Owner: "",
Group: "",
Mode: 0654,
}).SetPermission(path)

stat, err := f.Stat()
require.NoError(t, err)

assert.Equal(t, os.FileMode(0654), stat.Mode())

require.NoError(t, f.Close())
require.NoError(t, os.Remove(path))
}

func TestLoginConsentURL(t *testing.T) {
l := logrusx.New("", "")
l.Logrus().SetOutput(ioutil.Discard)
p := MustNew(l)
p.MustSet(KeyLoginURL, "http://localhost:8080/oauth/login")
p.MustSet(KeyConsentURL, "http://localhost:8080/oauth/consent")

assert.Equal(t, "http://localhost:8080/oauth/login", p.LoginURL().String())
assert.Equal(t, "http://localhost:8080/oauth/consent", p.ConsentURL().String())

p2 := MustNew(l)
p2.MustSet(KeyLoginURL, "http://localhost:3000/#/oauth/login")
p2.MustSet(KeyConsentURL, "http://localhost:3000/#/oauth/consent")

assert.Equal(t, "http://localhost:3000/#/oauth/login", p2.LoginURL().String())
assert.Equal(t, "http://localhost:3000/#/oauth/consent", p2.ConsentURL().String())
}

0 comments on commit 3e3efbd

Please sign in to comment.