Skip to content

Commit

Permalink
Add Support for VerificationMethod Attribute for Email-based Auth0 …
Browse files Browse the repository at this point in the history
…ConnectionOptions (#481)
  • Loading branch information
developerkunal authored Jan 8, 2025
1 parent b79eaef commit 6452713
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 47 deletions.
17 changes: 14 additions & 3 deletions management/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,22 @@ type ConnectionOptionsAttributeAllowedTypes struct {
PhoneNumber *bool `json:"phone_number,omitempty"`
}

// ConnectionOptionsEmailAttributeVerificationMethod defines the verification method for email attributes.
type ConnectionOptionsEmailAttributeVerificationMethod string

var (
// ConnectionOptionsEmailAttributeVerificationMethodLink is the "link" verification method.
ConnectionOptionsEmailAttributeVerificationMethodLink ConnectionOptionsEmailAttributeVerificationMethod = "link"
// ConnectionOptionsEmailAttributeVerificationMethodOtp is the "otp" verification method.
ConnectionOptionsEmailAttributeVerificationMethodOtp ConnectionOptionsEmailAttributeVerificationMethod = "otp"
)

// ConnectionOptionsEmailAttribute defines configuration settings for email attributes.
type ConnectionOptionsEmailAttribute struct {
Identifier *ConnectionOptionsAttributeIdentifier `json:"identifier,omitempty"`
ProfileRequired *bool `json:"profile_required,omitempty"`
Signup *ConnectionOptionsAttributeSignup `json:"signup,omitempty"`
Identifier *ConnectionOptionsAttributeIdentifier `json:"identifier,omitempty"`
ProfileRequired *bool `json:"profile_required,omitempty"`
Signup *ConnectionOptionsAttributeSignup `json:"signup,omitempty"`
VerificationMethod *ConnectionOptionsEmailAttributeVerificationMethod `json:"verification_method,omitempty"`
}

// ConnectionOptionsUsernameAttribute defines configuration settings for username attributes.
Expand Down
50 changes: 50 additions & 0 deletions management/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,56 @@ var Auth0ConnectionTestCase = []connectionTestCase{
},
},
},
{
name: "Auth0 Connection with Email as Identifier With VerificationMethod OTP",
connection: Connection{
Name: auth0.Stringf("Test-Auth0-Connection-Email-VerificationMethod-OTP%d", time.Now().Unix()),
Strategy: auth0.String("auth0"),
},
options: &ConnectionOptions{
Precedence: &[]string{"username", "email", "phone_number"},
Attributes: &ConnectionOptionsAttributes{
Email: &ConnectionOptionsEmailAttribute{
Identifier: &ConnectionOptionsAttributeIdentifier{
Active: auth0.Bool(true),
},
VerificationMethod: &ConnectionOptionsEmailAttributeVerificationMethodOtp,
ProfileRequired: auth0.Bool(true),
Signup: &ConnectionOptionsAttributeSignup{
Status: auth0.String("required"),
Verification: &ConnectionOptionsAttributeVerification{
Active: auth0.Bool(false),
},
},
},
},
},
},
{
name: "Auth0 Connection with Email as Identifier With VerificationMethod Link",
connection: Connection{
Name: auth0.Stringf("Test-Auth0-Connection-Email-VerificationMethod-Link%d", time.Now().Unix()),
Strategy: auth0.String("auth0"),
},
options: &ConnectionOptions{
Precedence: &[]string{"username", "email", "phone_number"},
Attributes: &ConnectionOptionsAttributes{
Email: &ConnectionOptionsEmailAttribute{
Identifier: &ConnectionOptionsAttributeIdentifier{
Active: auth0.Bool(true),
},
VerificationMethod: &ConnectionOptionsEmailAttributeVerificationMethodLink,
ProfileRequired: auth0.Bool(true),
Signup: &ConnectionOptionsAttributeSignup{
Status: auth0.String("required"),
Verification: &ConnectionOptionsAttributeVerification{
Active: auth0.Bool(false),
},
},
},
},
},
},
{
name: "Auth0 Connection with Username as Identifier",
connection: Connection{
Expand Down
8 changes: 8 additions & 0 deletions management/management.gen.go

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

7 changes: 7 additions & 0 deletions management/management.gen_test.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Attribute-Inactive-On-Signup-1728906681","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"inactive","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Attribute-Inactive-On-Signup-1736241923","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"inactive","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 471.043583ms
duration: 308.383ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Invalid-1728906681","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Invalid-1736241923","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 329.730458ms
duration: 346.371375ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Attributes-And-Validation-1728906681","strategy":"auth0","options":{"validation":{"username":{"max":5,"min":1}},"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required"}}}}}
{"name":"Test-Auth0-Connection-Attributes-And-Validation-1736241923","strategy":"auth0","options":{"validation":{"username":{"max":5,"min":1}},"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required"}}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 302.367458ms
duration: 392.242ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-No-Active-Attributes-1728906681","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required"}},"phone_number":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-No-Active-Attributes-1736241923","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required"}},"phone_number":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 320.710917ms
duration: 322.8135ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-RequireUsername-1728906681","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"]}}
{"name":"Test-Auth0-Connection-RequireUsername-1736241923","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"]}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -30,13 +30,13 @@ interactions:
trailer: {}
content_length: 626
uncompressed: false
body: '{"id":"con_RzNKTvGJOOD0XWpQ","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","requires_username":true,"precedence":["username","email","phone_number"],"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-RequireUsername-1728906681","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-RequireUsername-1728906681"]}'
body: '{"id":"con_VPCvXnnKfAMHSzyo","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","requires_username":true,"precedence":["username","email","phone_number"],"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-RequireUsername-1736241923","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-RequireUsername-1736241923"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 381.930375ms
duration: 1.117267875s
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -54,8 +54,8 @@ interactions:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_RzNKTvGJOOD0XWpQ
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_VPCvXnnKfAMHSzyo
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -65,10 +65,10 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2024-10-14T11:51:38.052Z"}'
body: '{"deleted_at":"2025-01-07T09:25:25.332Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 327.849042ms
duration: 349.379959ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Email-1728906681","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Email-1736241923","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -30,13 +30,13 @@ interactions:
trailer: {}
content_length: 751
uncompressed: false
body: '{"id":"con_pO21c5QWkSTcJcXf","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}},"verification_method":"link"}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Email-1728906681","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Email-1728906681"]}'
body: '{"id":"con_xgVCCjTqYLoboSGE","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}},"verification_method":"link"}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Email-1736241923","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Email-1736241923"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 355.708708ms
duration: 338.307416ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -54,8 +54,8 @@ interactions:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.11.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_pO21c5QWkSTcJcXf
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_xgVCCjTqYLoboSGE
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -65,10 +65,10 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2024-10-14T11:51:39.442Z"}'
body: '{"deleted_at":"2025-01-07T09:25:26.675Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 341.154ms
duration: 338.49175ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
version: 2
interactions:
- id: 0
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 323
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Email-VerificationMethod-Link1736241923","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}},"verification_method":"link"}}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 797
uncompressed: false
body: '{"id":"con_ZfDvJ5SPDanfkNG9","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}},"verification_method":"link"}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Email-VerificationMethod-Link1736241923","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Email-VerificationMethod-Link1736241923"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 372.6005ms
- id: 1
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.13.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_ZfDvJ5SPDanfkNG9
method: DELETE
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2025-01-07T09:25:28.152Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 364.434834ms
Loading

0 comments on commit 6452713

Please sign in to comment.