Skip to content

Commit 324c3c3

Browse files
committed
feat: support prompt=create
1 parent e3f450e commit 324c3c3

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

consent/strategy_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (s *DefaultStrategy) forwardAuthenticationRequest(ctx context.Context, w ht
280280
}
281281

282282
var baseURL *url.URL
283-
if stringslice.Has(prompt, "registration") {
283+
if stringslice.Has(prompt, "registration") || stringslice.Has(prompt, "create") {
284284
baseURL = s.c.RegistrationURL(ctx)
285285
} else {
286286
baseURL = s.c.LoginURL(ctx)

oauth2/.snapshots/TestHandlerWellKnown-hsm_enabled=false.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,11 @@
9797
"userinfo_signing_alg_values_supported": [
9898
"none",
9999
"RS256"
100+
],
101+
"prompt_values_supported": [
102+
"none",
103+
"login",
104+
"consent",
105+
"select_account"
100106
]
101107
}

oauth2/.snapshots/TestHandlerWellKnown-hsm_enabled=true.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,11 @@
9797
"userinfo_signing_alg_values_supported": [
9898
"none",
9999
"RS256"
100+
],
101+
"prompt_values_supported": [
102+
"none",
103+
"login",
104+
"consent",
105+
"select_account"
100106
]
101107
}

oauth2/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ type oidcConfiguration struct {
427427
//
428428
// JSON array containing a list of the Verifiable Credentials supported by this authorization server.
429429
CredentialsSupportedDraft00 []CredentialSupportedDraft00 `json:"credentials_supported_draft_00"`
430+
431+
// Initiating User Registration via OpenID Connect 1.0
432+
//
433+
// JSON array containing the list of prompt values that this OP supports.
434+
PromptValuesSupported []string `json:"prompt_values_supported"`
430435
}
431436

432437
// Verifiable Credentials Metadata (Draft 00)
@@ -521,6 +526,7 @@ func (h *Handler) discoverOidcConfiguration(w http.ResponseWriter, r *http.Reque
521526
"EdDSA",
522527
},
523528
}},
529+
PromptValuesSupported: []string{"none", "login", "consent", "select_account", "create"},
524530
})
525531
}
526532

oauth2/oauth2_auth_code_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,27 @@ func TestAuthCodeWithDefaultStrategy(t *testing.T) {
648648

649649
assertIDToken(t, token, conf, subject, nonce, time.Now().Add(reg.Config().GetIDTokenLifespan(ctx)))
650650
})
651+
t.Run("case=perform flow with prompt=create", func(t *testing.T) {
652+
c, conf := newOAuth2Client(t, reg, testhelpers.NewCallbackURL(t, "callback", testhelpers.HTTPServerNotImplementedHandler))
653+
654+
regUI := httptest.NewServer(acceptLoginHandler(t, c, subject, nil))
655+
t.Cleanup(regUI.Close)
656+
reg.Config().MustSet(ctx, config.KeyRegistrationURL, regUI.URL)
657+
658+
testhelpers.NewLoginConsentUI(t, reg.Config(),
659+
nil,
660+
acceptConsentHandler(t, c, subject, nil))
661+
662+
code, _ := getAuthorizeCode(t, conf, nil,
663+
oauth2.SetAuthURLParam("prompt", "create"),
664+
oauth2.SetAuthURLParam("nonce", nonce))
665+
require.NotEmpty(t, code)
666+
667+
token, err := conf.Exchange(context.Background(), code)
668+
require.NoError(t, err)
669+
670+
assertIDToken(t, token, conf, subject, nonce, time.Now().Add(reg.Config().GetIDTokenLifespan(ctx)))
671+
})
651672

652673
t.Run("case=perform flow with audience", func(t *testing.T) {
653674
expectAud := "https://api.ory.sh/"

spec/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@
778778
},
779779
"registration": {
780780
"type": "string",
781-
"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.",
781+
"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.",
782782
"format": "uri-reference",
783783
"examples": [
784784
"https://my-login.app/registration",

0 commit comments

Comments
 (0)