Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions oidc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,9 @@ func unmarshalRespJSON(r *http.Response, body []byte, v interface{}) error {
}
return fmt.Errorf("%s: expected Content-Type = application/json, got %q and could not unmarshal it as JSON: %w", op, ct, err)
}

// Endpoint returns the oauth2 Endpoint information that the go-oidc
// provider already knows about from its probe of the Discovery URL
func (p *Provider) Endpoint() oauth2.Endpoint {
return p.provider.Endpoint()
}
12 changes: 12 additions & 0 deletions oidc/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,3 +1731,15 @@ func TestProvider_DiscoveryInfo(t *testing.T) {
})
}
}

func TestProvider_Endpoint(t *testing.T) {
t.Parallel()
tp := StartTestProvider(t)
p := testNewProvider(t, "client-id", "client-secret", "redirect", tp)

endpoint := p.Endpoint()
assert := assert.New(t)
assert.NotEqual(endpoint.AuthURL, "")
assert.NotEqual(endpoint.DeviceAuthURL, "")
assert.NotEqual(endpoint.TokenURL, "")
}
3 changes: 3 additions & 0 deletions oidc/testing_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ func (p *TestProvider) ServeHTTP(w http.ResponseWriter, req *http.Request) {
const (
openidConfiguration = "/.well-known/openid-configuration"
authorize = "/authorize"
deviceAuthorize = "/deviceauthorize"
token = "/token"
userInfo = "/userinfo"
wellKnownJwks = "/.well-known/jwks.json"
Expand Down Expand Up @@ -1160,6 +1161,7 @@ func (p *TestProvider) ServeHTTP(w http.ResponseWriter, req *http.Request) {
reply := struct {
Issuer string `json:"issuer"`
AuthEndpoint string `json:"authorization_endpoint"`
DeviceAuthEndpoint string `json:"device_authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
JWKSURI string `json:"jwks_uri"`
UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"`
Expand All @@ -1170,6 +1172,7 @@ func (p *TestProvider) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}{
Issuer: p.Addr(),
AuthEndpoint: p.Addr() + authorize,
DeviceAuthEndpoint: p.Addr() + deviceAuthorize,
TokenEndpoint: p.Addr() + token,
JWKSURI: p.Addr() + wellKnownJwks,
UserinfoEndpoint: p.Addr() + userInfo,
Expand Down