From fa326d9448880d584289f93e4840099e1ad46aee Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Tue, 19 Sep 2023 15:36:26 +0200 Subject: [PATCH 1/2] fix: wrong continue_with enum declaration --- ...del_continue_with_set_ory_session_token.go | 2 +- .../model_continue_with_verification_ui.go | 2 +- ...del_continue_with_set_ory_session_token.go | 2 +- .../model_continue_with_verification_ui.go | 2 +- selfservice/flow/continue_with.go | 33 +++++++++++-------- spec/api.json | 12 +++---- spec/swagger.json | 12 +++---- 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/internal/client-go/model_continue_with_set_ory_session_token.go b/internal/client-go/model_continue_with_set_ory_session_token.go index 641718339f88..e091665d0d00 100644 --- a/internal/client-go/model_continue_with_set_ory_session_token.go +++ b/internal/client-go/model_continue_with_set_ory_session_token.go @@ -17,7 +17,7 @@ import ( // ContinueWithSetOrySessionToken Indicates that a session was issued, and the application should use this token for authenticated requests type ContinueWithSetOrySessionToken struct { - // Action will always be `set_ory_session_token` set_ory_session_token ContinueWithActionSetOrySessionToken show_verification_ui ContinueWithActionShowVerificationUI + // Action will always be `set_ory_session_token` set_ory_session_token ContinueWithActionSetOrySessionTokenString Action string `json:"action"` // Token is the token of the session OrySessionToken string `json:"ory_session_token"` diff --git a/internal/client-go/model_continue_with_verification_ui.go b/internal/client-go/model_continue_with_verification_ui.go index 987c32d18f2e..38ca91116469 100644 --- a/internal/client-go/model_continue_with_verification_ui.go +++ b/internal/client-go/model_continue_with_verification_ui.go @@ -17,7 +17,7 @@ import ( // ContinueWithVerificationUi Indicates, that the UI flow could be continued by showing a verification ui type ContinueWithVerificationUi struct { - // Action will always be `show_verification_ui` set_ory_session_token ContinueWithActionSetOrySessionToken show_verification_ui ContinueWithActionShowVerificationUI + // Action will always be `show_verification_ui` show_verification_ui ContinueWithActionShowVerificationUIString Action string `json:"action"` Flow ContinueWithVerificationUiFlow `json:"flow"` } diff --git a/internal/httpclient/model_continue_with_set_ory_session_token.go b/internal/httpclient/model_continue_with_set_ory_session_token.go index 641718339f88..e091665d0d00 100644 --- a/internal/httpclient/model_continue_with_set_ory_session_token.go +++ b/internal/httpclient/model_continue_with_set_ory_session_token.go @@ -17,7 +17,7 @@ import ( // ContinueWithSetOrySessionToken Indicates that a session was issued, and the application should use this token for authenticated requests type ContinueWithSetOrySessionToken struct { - // Action will always be `set_ory_session_token` set_ory_session_token ContinueWithActionSetOrySessionToken show_verification_ui ContinueWithActionShowVerificationUI + // Action will always be `set_ory_session_token` set_ory_session_token ContinueWithActionSetOrySessionTokenString Action string `json:"action"` // Token is the token of the session OrySessionToken string `json:"ory_session_token"` diff --git a/internal/httpclient/model_continue_with_verification_ui.go b/internal/httpclient/model_continue_with_verification_ui.go index 987c32d18f2e..38ca91116469 100644 --- a/internal/httpclient/model_continue_with_verification_ui.go +++ b/internal/httpclient/model_continue_with_verification_ui.go @@ -17,7 +17,7 @@ import ( // ContinueWithVerificationUi Indicates, that the UI flow could be continued by showing a verification ui type ContinueWithVerificationUi struct { - // Action will always be `show_verification_ui` set_ory_session_token ContinueWithActionSetOrySessionToken show_verification_ui ContinueWithActionShowVerificationUI + // Action will always be `show_verification_ui` show_verification_ui ContinueWithActionShowVerificationUIString Action string `json:"action"` Flow ContinueWithVerificationUiFlow `json:"flow"` } diff --git a/selfservice/flow/continue_with.go b/selfservice/flow/continue_with.go index 0b22b8b8ecb3..5d6eb6ff1619 100644 --- a/selfservice/flow/continue_with.go +++ b/selfservice/flow/continue_with.go @@ -14,24 +14,23 @@ import ( // swagger:model continueWith type ContinueWith any -// swagger:enum ContinueWithAction -type ContinueWithAction string +// swagger:enum ContinueWithActionSetOrySessionToken +type ContinueWithActionSetOrySessionToken string // #nosec G101 -- only a key constant const ( - ContinueWithActionSetOrySessionToken ContinueWithAction = "set_ory_session_token" - ContinueWithActionShowVerificationUI ContinueWithAction = "show_verification_ui" + ContinueWithActionSetOrySessionTokenString ContinueWithActionSetOrySessionToken = "set_ory_session_token" ) -var _ ContinueWith = new(ContinueWithSetToken) +var _ ContinueWith = new(ContinueWithSetOrySessionToken) // Indicates that a session was issued, and the application should use this token for authenticated requests // swagger:model continueWithSetOrySessionToken -type ContinueWithSetToken struct { +type ContinueWithSetOrySessionToken struct { // Action will always be `set_ory_session_token` // // required: true - Action ContinueWithAction `json:"action"` + Action ContinueWithActionSetOrySessionToken `json:"action"` // Token is the token of the session // @@ -39,17 +38,25 @@ type ContinueWithSetToken struct { OrySessionToken string `json:"ory_session_token"` } -func (ContinueWithSetToken) AppendTo(url.Values) url.Values { +func (ContinueWithSetOrySessionToken) AppendTo(url.Values) url.Values { return nil } -func NewContinueWithSetToken(t string) *ContinueWithSetToken { - return &ContinueWithSetToken{ - Action: ContinueWithActionSetOrySessionToken, +func NewContinueWithSetToken(t string) *ContinueWithSetOrySessionToken { + return &ContinueWithSetOrySessionToken{ + Action: ContinueWithActionSetOrySessionTokenString, OrySessionToken: t, } } +// swagger:enum ContinueWithActionShowVerificationUI +type ContinueWithActionShowVerificationUI string + +// #nosec G101 -- only a key constant +const ( + ContinueWithActionShowVerificationUIString ContinueWithActionShowVerificationUI = "show_verification_ui" +) + var _ ContinueWith = new(ContinueWithVerificationUI) // Indicates, that the UI flow could be continued by showing a verification ui @@ -59,7 +66,7 @@ type ContinueWithVerificationUI struct { // Action will always be `show_verification_ui` // // required: true - Action ContinueWithAction `json:"action"` + Action ContinueWithActionShowVerificationUI `json:"action"` // Flow contains the ID of the verification flow // // required: true @@ -86,7 +93,7 @@ type ContinueWithVerificationUIFlow struct { func NewContinueWithVerificationUI(f Flow, address, url string) *ContinueWithVerificationUI { return &ContinueWithVerificationUI{ - Action: ContinueWithActionShowVerificationUI, + Action: ContinueWithActionShowVerificationUIString, Flow: ContinueWithVerificationUIFlow{ ID: f.GetID(), VerifiableAddress: address, diff --git a/spec/api.json b/spec/api.json index 06cd193d9edc..d163cd2d65f6 100644 --- a/spec/api.json +++ b/spec/api.json @@ -478,13 +478,12 @@ "description": "Indicates that a session was issued, and the application should use this token for authenticated requests", "properties": { "action": { - "description": "Action will always be `set_ory_session_token`\nset_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI", + "description": "Action will always be `set_ory_session_token`\nset_ory_session_token ContinueWithActionSetOrySessionTokenString", "enum": [ - "set_ory_session_token", - "show_verification_ui" + "set_ory_session_token" ], "type": "string", - "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI" + "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionTokenString" }, "ory_session_token": { "description": "Token is the token of the session", @@ -501,13 +500,12 @@ "description": "Indicates, that the UI flow could be continued by showing a verification ui", "properties": { "action": { - "description": "Action will always be `show_verification_ui`\nset_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI", + "description": "Action will always be `show_verification_ui`\nshow_verification_ui ContinueWithActionShowVerificationUIString", "enum": [ - "set_ory_session_token", "show_verification_ui" ], "type": "string", - "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI" + "x-go-enum-desc": "show_verification_ui ContinueWithActionShowVerificationUIString" }, "flow": { "$ref": "#/components/schemas/continueWithVerificationUiFlow" diff --git a/spec/swagger.json b/spec/swagger.json index 7d4321cf0b78..df1b67be4013 100755 --- a/spec/swagger.json +++ b/spec/swagger.json @@ -3519,13 +3519,12 @@ ], "properties": { "action": { - "description": "Action will always be `set_ory_session_token`\nset_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI", + "description": "Action will always be `set_ory_session_token`\nset_ory_session_token ContinueWithActionSetOrySessionTokenString", "type": "string", "enum": [ - "set_ory_session_token", - "show_verification_ui" + "set_ory_session_token" ], - "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI" + "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionTokenString" }, "ory_session_token": { "description": "Token is the token of the session", @@ -3542,13 +3541,12 @@ ], "properties": { "action": { - "description": "Action will always be `show_verification_ui`\nset_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI", + "description": "Action will always be `show_verification_ui`\nshow_verification_ui ContinueWithActionShowVerificationUIString", "type": "string", "enum": [ - "set_ory_session_token", "show_verification_ui" ], - "x-go-enum-desc": "set_ory_session_token ContinueWithActionSetOrySessionToken\nshow_verification_ui ContinueWithActionShowVerificationUI" + "x-go-enum-desc": "show_verification_ui ContinueWithActionShowVerificationUIString" }, "flow": { "$ref": "#/definitions/continueWithVerificationUiFlow" From 5a9e53cc901f93735ccfefee39d4d6d5d4517281 Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Tue, 19 Sep 2023 16:12:21 +0200 Subject: [PATCH 2/2] chore: compile --- selfservice/hook/session_issuer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfservice/hook/session_issuer_test.go b/selfservice/hook/session_issuer_test.go index db62ab2d643d..c58faec0fb2f 100644 --- a/selfservice/hook/session_issuer_test.go +++ b/selfservice/hook/session_issuer_test.go @@ -76,8 +76,8 @@ func TestSessionIssuer(t *testing.T) { require.Len(t, f.ContinueWithItems, 1) st := f.ContinueWithItems[0] - require.IsType(t, &flow.ContinueWithSetToken{}, st) - assert.NotEmpty(t, st.(*flow.ContinueWithSetToken).OrySessionToken) + require.IsType(t, &flow.ContinueWithSetOrySessionToken{}, st) + assert.NotEmpty(t, st.(*flow.ContinueWithSetOrySessionToken).OrySessionToken) got, err := reg.SessionPersister().GetSession(context.Background(), s.ID, session.ExpandNothing) require.NoError(t, err)