mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
authorize: move sign out and jwks urls to route, update issuer for JWT (#4046)
* authorize: move sign out and jwks urls to route, update issuer for JWT * fix test
This commit is contained in:
parent
376bfe053d
commit
1dee325b72
10 changed files with 36 additions and 34 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/pomerium/csrf"
|
||||
"github.com/pomerium/pomerium/internal/httputil"
|
||||
"github.com/pomerium/pomerium/internal/urlutil"
|
||||
)
|
||||
|
||||
// WellKnownPomerium returns the /.well-known/pomerium handler.
|
||||
|
@ -19,8 +20,8 @@ func WellKnownPomerium(authenticateURL *url.URL) http.Handler {
|
|||
FrontchannelLogoutURI string `json:"frontchannel_logout_uri"` // https://openid.net/specs/openid-connect-frontchannel-1_0.html
|
||||
}{
|
||||
authenticateURL.ResolveReference(&url.URL{Path: "/oauth2/callback"}).String(),
|
||||
authenticateURL.ResolveReference(&url.URL{Path: "/.well-known/pomerium/jwks.json"}).String(),
|
||||
authenticateURL.ResolveReference(&url.URL{Path: "/.pomerium/sign_out"}).String(),
|
||||
urlutil.GetAbsoluteURL(r).ResolveReference(&url.URL{Path: "/.well-known/pomerium/jwks.json"}).String(),
|
||||
urlutil.GetAbsoluteURL(r).ResolveReference(&url.URL{Path: "/.pomerium/sign_out"}).String(),
|
||||
}
|
||||
w.Header().Set("X-CSRF-Token", csrf.Token(r))
|
||||
httputil.RenderJSON(w, http.StatusOK, wellKnownURLs)
|
||||
|
|
|
@ -21,4 +21,15 @@ func TestWellKnownPomeriumHandler(t *testing.T) {
|
|||
WellKnownPomerium(authenticateURL).ServeHTTP(w, r)
|
||||
assert.Equal(t, http.StatusNoContent, w.Result().StatusCode)
|
||||
})
|
||||
t.Run("links", func(t *testing.T) {
|
||||
authenticateURL, _ := url.Parse("https://authenticate.example.com")
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodGet, "https://route.example.com", nil)
|
||||
WellKnownPomerium(authenticateURL).ServeHTTP(w, r)
|
||||
assert.JSONEq(t, `{
|
||||
"authentication_callback_endpoint": "https://authenticate.example.com/oauth2/callback",
|
||||
"frontchannel_logout_uri": "https://route.example.com/.pomerium/sign_out",
|
||||
"jwks_uri": "https://route.example.com/.well-known/pomerium/jwks.json"
|
||||
}`, w.Body.String())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue