-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: android app expects 6 digit verification code (PS-186) (cherry picked from commit c4d8cdc) feat: reduce verification code length to 4 (PS-183) (cherry picked from commit af55347) feat: add url link to SMS phone verification message (PS-153) (cherry picked from commit 0d5a9ab) fix: sort ui nodes when `code` is added - add test (PS-144) (cherry picked from commit e1dd6ae) fix: sort ui nodes when `code` is added (PS-144) (cherry picked from commit 9a120fc) feat: set flow active method for `code` strategy (PS-144) (cherry picked from commit 71ba520) feat: set transient_payload to `code` method registration flow (PS-122) (cherry picked from commit 83de4a5) ignore: add TemplateData to sms message body template context (CORE-2361) (cherry picked from commit f0eff32) ignore: fix flaky test (CORE-2361) (cherry picked from commit 485e7cc) feat: add `transient_payload` to `code` login and register flows (CORE-2361) (cherry picked from commit e103508) fix(sms-login): error handling for invalid sms code (cherry picked from commit 781dfe1) fix(sms-login): verify phones with code even if verification.use = link (cherry picked from commit 9e0f4b1) feat: sms-login initial commit fix: change group for 'identifier' field feat: add sms spam protection to `code` strategy fix: delete credential identifier if trait deleted fix: sms spam protection 'like' clause fix: Validate and normalize phone numbers chore: format feat: normalize phone number if used as identifier fix: correctly process invalid phone numbers feat: add standby SMS service (cherry picked from commit a972194)
- Loading branch information
Showing
78 changed files
with
2,901 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
courier/template/courier/builtin/templates/login/sms.body.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
code {{ .Code }} |
1 change: 1 addition & 0 deletions
1
courier/template/courier/builtin/templates/registration_code/valid/sms.body.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Your registration code is: {{ .RegistrationCode }} |
1 change: 1 addition & 0 deletions
1
courier/template/courier/builtin/templates/test_stub/sms.body.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
stub sms body {{ .Body }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package sms | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/ory/kratos/courier/template" | ||
) | ||
|
||
type ( | ||
RegistrationCodeValid struct { | ||
deps template.Dependencies | ||
model *RegistrationCodeValidModel | ||
} | ||
RegistrationCodeValidModel struct { | ||
To string | ||
RegistrationCode string | ||
Traits map[string]interface{} | ||
TransientPayload json.RawMessage | ||
} | ||
) | ||
|
||
func NewRegistrationCodeValid(d template.Dependencies, m *RegistrationCodeValidModel) *RegistrationCodeValid { | ||
return &RegistrationCodeValid{deps: d, model: m} | ||
} | ||
|
||
func (t *RegistrationCodeValid) PhoneNumber() (string, error) { | ||
return t.model.To, nil | ||
} | ||
|
||
func (t *RegistrationCodeValid) SMSBody(ctx context.Context) (string, error) { | ||
return template.LoadText( | ||
ctx, | ||
t.deps, | ||
os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), | ||
"registration_code/valid/sms.body.gotmpl", | ||
"registration_code/valid/sms.body*", | ||
t.model, | ||
t.deps.CourierConfig().CourierSMSTemplatesLoginCodeValid(ctx).Body.PlainText, | ||
) | ||
} | ||
|
||
func (t *RegistrationCodeValid) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(t.model) | ||
} | ||
|
||
func (t *RegistrationCodeValid) TemplateType() template.TemplateType { | ||
return template.TypeRegistrationCodeValid | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ package identity | |
|
||
const ( | ||
AddressTypeEmail = "email" | ||
AddressTypePhone = "sms" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package identity_test | |
import ( | ||
"bytes" | ||
"context" | ||
"errors" | ||
"fmt" | ||
"testing" | ||
|
||
|
@@ -36,6 +37,15 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
expect: []string{"[email protected]"}, | ||
ct: identity.CredentialsTypePassword, | ||
}, | ||
{ | ||
doc: `{}`, | ||
schema: "file://./stub/extension/credentials/schema.json", | ||
expect: []string{}, | ||
existing: &identity.Credentials{ | ||
Identifiers: []string{"[email protected]"}, | ||
}, | ||
ct: identity.CredentialsTypePassword, | ||
}, | ||
{ | ||
doc: `{"emails":["[email protected]","[email protected]","[email protected]"], "username": "foobar"}`, | ||
schema: "file://./stub/extension/credentials/multi.schema.json", | ||
|
@@ -87,6 +97,18 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
}, | ||
ct: identity.CredentialsTypeCodeAuth, | ||
}, | ||
{ | ||
doc: `{"phone":"not-valid-number"}`, | ||
schema: "file://./stub/extension/credentials/code.schema.json", | ||
ct: identity.CredentialsTypeCodeAuth, | ||
expectErr: errors.New("I[#/phone] S[#/properties/phone] validation failed\n I[#/phone] S[#/properties/phone/format] \"not-valid-number\" is not valid \"tel\"\n I[#/phone] S[#/properties/phone/format] the phone number supplied is not a number"), | ||
}, | ||
{ | ||
doc: `{"phone":"+4407376494399"}`, | ||
schema: "file://./stub/extension/credentials/code.schema.json", | ||
expect: []string{"+447376494399"}, | ||
ct: identity.CredentialsTypeCodeAuth, | ||
}, | ||
} { | ||
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) { | ||
c := jsonschema.NewCompiler() | ||
|
@@ -103,12 +125,16 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
err = c.MustCompile(ctx, tc.schema).Validate(bytes.NewBufferString(tc.doc)) | ||
if tc.expectErr != nil { | ||
require.EqualError(t, err, tc.expectErr.Error()) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
require.NoError(t, e.Finish()) | ||
|
||
credentials, ok := i.GetCredentials(tc.ct) | ||
require.True(t, ok) | ||
assert.ElementsMatch(t, tc.expect, credentials.Identifiers) | ||
if tc.expectErr == nil { | ||
credentials, ok := i.GetCredentials(tc.ct) | ||
require.True(t, ok) | ||
assert.ElementsMatch(t, tc.expect, credentials.Identifiers) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.