Skip to content

Commit edb0f1e

Browse files
Merge branch 'main' into retry-per-request
2 parents 5fda310 + 0bf1560 commit edb0f1e

7 files changed

+743
-1
lines changed

management/client.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ type Client struct {
142142
DefaultOrganization *ClientDefaultOrganization `json:"default_organization,omitempty"`
143143

144144
TokenExchange *ClientTokenExchange `json:"token_exchange,omitempty"`
145+
146+
// Session Transfer settings for the client - Allows Native to Web SSO
147+
SessionTransfer *SessionTransfer `json:"session_transfer,omitempty"`
145148
}
146149

147150
// ClientTokenExchange allows configuration for token exchange.
@@ -278,6 +281,18 @@ type ClientRefreshToken struct {
278281

279282
// Period in seconds after which inactive refresh tokens will expire.
280283
IdleTokenLifetime *int `json:"idle_token_lifetime,omitempty"`
284+
285+
// A collection of policies governing multi-resource refresh token exchange (MRRT), defining how refresh tokens can be used across different resource servers
286+
Policies *[]ClientRefreshTokenPolicy `json:"policies,omitempty"`
287+
}
288+
289+
// ClientRefreshTokenPolicy is used to configure the Refresh Token policies for our Client.
290+
type ClientRefreshTokenPolicy struct {
291+
// The identifier of the resource server to which the Multi Resource Refresh Token Policy applies
292+
Audience *string `json:"audience,omitempty"`
293+
294+
// The resource server permissions granted under the Multi Resource Refresh Token Policy, defining the context in which an access token can be used
295+
Scope *[]string `json:"scope,omitempty"`
281296
}
282297

283298
// Credential is used to configure Client Credentials.
@@ -358,6 +373,13 @@ type BackChannelLogoutInitiators struct {
358373
SelectedInitiators *[]string `json:"selected_initiators,omitempty"`
359374
}
360375

376+
// SessionTransfer Transfer defines the setting to allow Native to Web SSO session transfer.
377+
type SessionTransfer struct {
378+
CanCreateSessionTransferToken *bool `json:"can_create_session_transfer_token,omitempty"`
379+
AllowedAuthenticationMethods *[]string `json:"allowed_authentication_methods,omitempty"`
380+
EnforceDeviceBinding *string `json:"enforce_device_binding,omitempty"`
381+
}
382+
361383
// ClientAddons defines the `addons` settings for a Client.
362384
type ClientAddons struct {
363385
AWS *AWSClientAddon `json:"aws,omitempty"`

management/client_test.go

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,61 @@ func TestClient_Create(t *testing.T) {
3030
})
3131
}
3232

33+
func TestClient_CreateWithClientRefreshToken(t *testing.T) {
34+
configureHTTPTestRecordings(t)
35+
36+
// Create a Resource Server
37+
resourceServer := &ResourceServer{
38+
Name: auth0.Stringf("Test Resource Server (%s)", time.Now().Format(time.StampMilli)),
39+
Identifier: auth0.String("https://mrrt"),
40+
Scopes: &[]ResourceServerScope{
41+
{
42+
Description: auth0.String("This is just a test client."),
43+
Value: auth0.String("create:bar"),
44+
},
45+
{
46+
Description: auth0.String("This is just a test client."),
47+
Value: auth0.String("read:bar"),
48+
},
49+
},
50+
SkipConsentForVerifiableFirstPartyClients: auth0.Bool(true),
51+
AllowOfflineAccess: auth0.Bool(true),
52+
}
53+
54+
err := api.ResourceServer.Create(context.Background(), resourceServer)
55+
assert.NoError(t, err)
56+
assert.NotEmpty(t, resourceServer.GetID())
57+
t.Cleanup(func() {
58+
cleanupResourceServer(t, resourceServer.GetID())
59+
})
60+
61+
// Create a Client with Refresh Token
62+
expectedClient := &Client{
63+
Name: auth0.Stringf("Test Client (%s)", time.Now().Format(time.StampMilli)),
64+
Description: auth0.String("This is just a test client."),
65+
IsFirstParty: auth0.Bool(true),
66+
RefreshToken: &ClientRefreshToken{
67+
ExpirationType: auth0.String("expiring"),
68+
RotationType: auth0.String("non-rotating"),
69+
Policies: &[]ClientRefreshTokenPolicy{
70+
{
71+
Audience: auth0.String(resourceServer.GetIdentifier()),
72+
Scope: &[]string{"create:bar", "read:bar"},
73+
},
74+
},
75+
},
76+
}
77+
err = api.Client.Create(context.Background(), expectedClient)
78+
assert.NoError(t, err)
79+
assert.NotEmpty(t, expectedClient.GetClientID())
80+
actualClient, err := api.Client.Read(context.Background(), expectedClient.GetClientID())
81+
assert.NoError(t, err)
82+
assert.Equal(t, expectedClient.GetRefreshToken(), actualClient.GetRefreshToken())
83+
t.Cleanup(func() {
84+
cleanupClient(t, expectedClient.GetClientID())
85+
})
86+
}
87+
3388
func TestClient_CreateWithTokenExchange(t *testing.T) {
3489
configureHTTPTestRecordings(t)
3590

@@ -45,7 +100,6 @@ func TestClient_CreateWithTokenExchange(t *testing.T) {
45100
err := api.Client.Create(context.Background(), expectedClient)
46101
assert.NoError(t, err)
47102
assert.NotEmpty(t, expectedClient.GetClientID())
48-
49103
actualClient, err := api.Client.Read(context.Background(), expectedClient.GetClientID())
50104
assert.NoError(t, err)
51105
assert.Equal(t, expectedClient.GetTokenExchange(), actualClient.GetTokenExchange())
@@ -54,6 +108,71 @@ func TestClient_CreateWithTokenExchange(t *testing.T) {
54108
})
55109
}
56110

111+
func TestClient_SessionTransfer(t *testing.T) {
112+
configureHTTPTestRecordings(t)
113+
114+
ctx := context.Background()
115+
116+
clientName := auth0.Stringf("Test Client SessionTransfer (%s)", time.Now().Format(time.StampMilli))
117+
expectedClient := &Client{
118+
Name: clientName,
119+
Description: auth0.String("This is a test client with Session Transfer."),
120+
SessionTransfer: &SessionTransfer{
121+
CanCreateSessionTransferToken: auth0.Bool(true),
122+
AllowedAuthenticationMethods: &[]string{"cookie", "query"},
123+
EnforceDeviceBinding: auth0.String("ip"),
124+
},
125+
}
126+
127+
// Create client
128+
require.NoError(t, api.Client.Create(ctx, expectedClient))
129+
require.NotEmpty(t, expectedClient.GetClientID())
130+
131+
t.Cleanup(func() {
132+
cleanupClient(t, expectedClient.GetClientID())
133+
})
134+
135+
// Verify creation
136+
created, err := api.Client.Read(ctx, expectedClient.GetClientID())
137+
require.NoError(t, err)
138+
require.NotNil(t, created.SessionTransfer)
139+
assert.Equal(t, expectedClient.GetSessionTransfer(), created.GetSessionTransfer())
140+
141+
// Update session transfer
142+
created.SessionTransfer = &SessionTransfer{
143+
CanCreateSessionTransferToken: auth0.Bool(false),
144+
AllowedAuthenticationMethods: &[]string{"cookie"},
145+
EnforceDeviceBinding: auth0.String("none"),
146+
}
147+
148+
// Strip fields not allowed on update
149+
created.ClientID = nil
150+
created.SigningKeys = nil
151+
if created.JWTConfiguration != nil {
152+
created.JWTConfiguration.SecretEncoded = nil
153+
}
154+
155+
require.NoError(t, api.Client.Update(ctx, expectedClient.GetClientID(), created))
156+
157+
// Verify update
158+
updated, err := api.Client.Read(ctx, expectedClient.GetClientID())
159+
require.NoError(t, err)
160+
require.NotNil(t, updated.SessionTransfer)
161+
assert.Equal(t, created.GetSessionTransfer(), updated.GetSessionTransfer())
162+
163+
// Remove session transfer via PATCH
164+
type clientPatch struct {
165+
SessionTransfer *SessionTransfer `json:"session_transfer"`
166+
}
167+
patch := &clientPatch{SessionTransfer: nil}
168+
require.NoError(t, api.Request(ctx, http.MethodPatch, api.URI("clients", expectedClient.GetClientID()), patch))
169+
170+
// Verify removal
171+
final, err := api.Client.Read(ctx, expectedClient.GetClientID())
172+
require.NoError(t, err)
173+
assert.Nil(t, final.GetSessionTransfer())
174+
}
175+
57176
func TestClient_CreateWithDefaultOrg(t *testing.T) {
58177
configureHTTPTestRecordings(t)
59178

management/connection.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ type ConnectionOptions struct {
444444
// - Combining `attributes` and `validation` in the same configuration is not allowed.
445445
// - If any identifier is required in the profile, it must be active during signup.
446446
Attributes *ConnectionOptionsAttributes `json:"attributes,omitempty"`
447+
448+
// Set to true to consume feature only when connections_realm_fallback flag is enabled for tenant
449+
RealmFallback *bool `json:"realm_fallback,omitempty"`
447450
}
448451

449452
// ConnectionOptionsAttributes defines the structure for attribute configurations.

management/management.gen.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)