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

feat: Support prompt=create #3813

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion consent/strategy_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (s *DefaultStrategy) forwardAuthenticationRequest(ctx context.Context, w ht
}

var baseURL *url.URL
if stringslice.Has(prompt, "registration") {
if stringslice.Has(prompt, "registration") || stringslice.Has(prompt, "create") {
baseURL = s.c.RegistrationURL(ctx)
} else {
baseURL = s.c.LoginURL(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,11 @@
"userinfo_signing_alg_values_supported": [
"none",
"RS256"
],
"prompt_values_supported": [
"none",
"login",
"consent",
"select_account"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,11 @@
"userinfo_signing_alg_values_supported": [
"none",
"RS256"
],
"prompt_values_supported": [
"none",
"login",
"consent",
"select_account"
]
}
6 changes: 6 additions & 0 deletions oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ type oidcConfiguration struct {
//
// JSON array containing a list of the Verifiable Credentials supported by this authorization server.
CredentialsSupportedDraft00 []CredentialSupportedDraft00 `json:"credentials_supported_draft_00"`

// Initiating User Registration via OpenID Connect 1.0
//
// JSON array containing the list of prompt values that this OP supports.
PromptValuesSupported []string `json:"prompt_values_supported"`
}

// Verifiable Credentials Metadata (Draft 00)
Expand Down Expand Up @@ -521,6 +526,7 @@ func (h *Handler) discoverOidcConfiguration(w http.ResponseWriter, r *http.Reque
"EdDSA",
},
}},
PromptValuesSupported: []string{"none", "login", "consent", "select_account", "create"},
})
}

Expand Down
21 changes: 21 additions & 0 deletions oauth2/oauth2_auth_code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,27 @@ func TestAuthCodeWithDefaultStrategy(t *testing.T) {

assertIDToken(t, token, conf, subject, nonce, time.Now().Add(reg.Config().GetIDTokenLifespan(ctx)))
})
t.Run("case=perform flow with prompt=create", func(t *testing.T) {
c, conf := newOAuth2Client(t, reg, testhelpers.NewCallbackURL(t, "callback", testhelpers.HTTPServerNotImplementedHandler))

regUI := httptest.NewServer(acceptLoginHandler(t, c, subject, nil))
t.Cleanup(regUI.Close)
reg.Config().MustSet(ctx, config.KeyRegistrationURL, regUI.URL)

testhelpers.NewLoginConsentUI(t, reg.Config(),
nil,
acceptConsentHandler(t, c, subject, nil))

code, _ := getAuthorizeCode(t, conf, nil,
oauth2.SetAuthURLParam("prompt", "create"),
oauth2.SetAuthURLParam("nonce", nonce))
require.NotEmpty(t, code)

token, err := conf.Exchange(context.Background(), code)
require.NoError(t, err)

assertIDToken(t, token, conf, subject, nonce, time.Now().Add(reg.Config().GetIDTokenLifespan(ctx)))
})

t.Run("case=perform flow with audience", func(t *testing.T) {
expectAud := "https://api.ory.sh/"
Expand Down
2 changes: 1 addition & 1 deletion spec/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@
},
"registration": {
"type": "string",
"description": "Sets the OAuth2 Registration Endpoint URL of the OAuth2 User Login & Consent flow. Defaults to the same value as `login`. The registration URL is used if the authorization request was started with the `prompt=registration` parameter.",
"description": "Sets the OAuth2 Registration Endpoint URL of the OAuth2 User Login & Consent flow. Defaults to the same value as `login`. The registration URL is used if the authorization request was started with the `prompt=registration` or `prompt=create` parameter.",
"format": "uri-reference",
"examples": [
"https://my-login.app/registration",
Expand Down
Loading