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

fix: wrong continue_with enum declaration #3522

Merged
merged 3 commits into from
Sep 20, 2023
Merged
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 20 additions & 13 deletions selfservice/flow/continue_with.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,49 @@ 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
//
// required: true
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
Expand All @@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions selfservice/hook/session_issuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
Loading