Skip to content

Commit 22ede61

Browse files
feat(generated): UserManagement, Radar (batch f510ddfb) (#416)
Co-authored-by: workos-sdk-automation[bot] <255426317+workos-sdk-automation[bot]@users.noreply.github.com>
1 parent b7a1009 commit 22ede61

28 files changed

Lines changed: 284 additions & 49 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* [#416](https://github.com/workos/workos-php/pull/416) fix(generated): regenerate from spec
2+
3+
**Features**
4+
* **[user_management](https://workos.com/docs/reference/authkit/user)**:
5+
* Added model `UserRoleAssignmentSource`
6+
* Added `source` to `UserRoleAssignment`
7+
* Added enum `UserRoleAssignmentSourceType`
8+
* Added parameter `UserManagementAuthentication.authorize.max_age`
9+
* Added endpoint `GET /user_management/cors_origins`
10+
* Added endpoint `GET /user_management/redirect_uris`
11+
12+
**Fixes**
13+
* Restore mistakenly removed CreateMagicAuth logic from previous release

.last-synced-sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4b4e0618779460dbebc1cf5e0f02197c21796d1f
1+
23faa38318d596e581656934ed72c4a18476d742

.oagen-manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"version": 2,
33
"language": "php",
4-
"generatedAt": "2026-07-02T17:29:52.899Z",
54
"files": [
65
"lib/Resource/ActionAuthenticationDenied.php",
76
"lib/Resource/ActionAuthenticationDeniedData.php",

lib/Resource/MagicAuthSendMagicAuthCodeAndReturnResponse.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
use JsonSerializableTrait;
1212

1313
public function __construct(
14+
/** Distinguishes the Magic Auth object. */
15+
public string $object,
16+
/** The unique ID of the Magic Auth code. */
17+
public string $id,
18+
/** The unique ID of the user. */
19+
public string $userId,
20+
/** The email address of the user. */
21+
public string $email,
22+
/** The timestamp when the Magic Auth code expires. */
23+
public \DateTimeImmutable $expiresAt,
24+
/** An ISO 8601 timestamp. */
25+
public \DateTimeImmutable $createdAt,
26+
/** An ISO 8601 timestamp. */
27+
public \DateTimeImmutable $updatedAt,
28+
/** The code used to verify the Magic Auth code. */
29+
public string $code,
1430
/** The ID of the Radar authentication attempt created for this request when Radar is enabled. Pass this value to the authenticate endpoint to associate the subsequent authentication with this Radar attempt. */
1531
public ?string $radarAuthAttemptId = null,
1632
) {
@@ -19,13 +35,29 @@ public function __construct(
1935
public static function fromArray(array $data): self
2036
{
2137
return new self(
38+
object: $data['object'] ?? 'magic_auth',
39+
id: $data['id'],
40+
userId: $data['user_id'],
41+
email: $data['email'],
42+
expiresAt: new \DateTimeImmutable($data['expires_at']),
43+
createdAt: new \DateTimeImmutable($data['created_at']),
44+
updatedAt: new \DateTimeImmutable($data['updated_at']),
45+
code: $data['code'],
2246
radarAuthAttemptId: $data['radar_auth_attempt_id'] ?? null,
2347
);
2448
}
2549

2650
public function toArray(): array
2751
{
2852
return [
53+
'object' => $this->object,
54+
'id' => $this->id,
55+
'user_id' => $this->userId,
56+
'email' => $this->email,
57+
'expires_at' => $this->expiresAt->format(\DateTimeInterface::RFC3339_EXTENDED),
58+
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
59+
'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED),
60+
'code' => $this->code,
2961
'radar_auth_attempt_id' => $this->radarAuthAttemptId,
3062
];
3163
}

lib/Resource/UserCreateResponse.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,37 @@
1111
use JsonSerializableTrait;
1212

1313
public function __construct(
14+
/** Distinguishes the user object. */
15+
public string $object,
16+
/** The unique ID of the user. */
17+
public string $id,
18+
/** The first name of the user. */
19+
public ?string $firstName,
20+
/** The last name of the user. */
21+
public ?string $lastName,
22+
/** A URL reference to an image representing the user. */
23+
public ?string $profilePictureUrl,
24+
/** The email address of the user. */
25+
public string $email,
26+
/** Whether the user's email has been verified. */
27+
public bool $emailVerified,
28+
/** The external ID of the user. */
29+
public ?string $externalId,
30+
/** The timestamp when the user last signed in. */
31+
public ?\DateTimeImmutable $lastSignInAt,
32+
/** An ISO 8601 timestamp. */
33+
public \DateTimeImmutable $createdAt,
34+
/** An ISO 8601 timestamp. */
35+
public \DateTimeImmutable $updatedAt,
36+
/** The user's full name. */
37+
public ?string $name = null,
38+
/**
39+
* Object containing metadata key/value pairs associated with the user.
40+
* @var array<string, string>|null
41+
*/
42+
public ?array $metadata = null,
43+
/** The user's preferred locale. */
44+
public ?string $locale = null,
1445
/** The ID of the Radar authentication attempt created for this request when Radar is enabled. Pass this value to the authenticate endpoint to associate the subsequent authentication with this Radar attempt. */
1546
public ?string $radarAuthAttemptId = null,
1647
) {
@@ -19,13 +50,41 @@ public function __construct(
1950
public static function fromArray(array $data): self
2051
{
2152
return new self(
53+
object: $data['object'] ?? 'user',
54+
id: $data['id'],
55+
firstName: $data['first_name'] ?? null,
56+
lastName: $data['last_name'] ?? null,
57+
profilePictureUrl: $data['profile_picture_url'] ?? null,
58+
email: $data['email'],
59+
emailVerified: $data['email_verified'],
60+
externalId: $data['external_id'] ?? null,
61+
lastSignInAt: isset($data['last_sign_in_at']) ? new \DateTimeImmutable($data['last_sign_in_at']) : null,
62+
createdAt: new \DateTimeImmutable($data['created_at']),
63+
updatedAt: new \DateTimeImmutable($data['updated_at']),
64+
name: $data['name'] ?? null,
65+
metadata: $data['metadata'] ?? null,
66+
locale: $data['locale'] ?? null,
2267
radarAuthAttemptId: $data['radar_auth_attempt_id'] ?? null,
2368
);
2469
}
2570

2671
public function toArray(): array
2772
{
2873
return [
74+
'object' => $this->object,
75+
'id' => $this->id,
76+
'first_name' => $this->firstName,
77+
'last_name' => $this->lastName,
78+
'profile_picture_url' => $this->profilePictureUrl,
79+
'email' => $this->email,
80+
'email_verified' => $this->emailVerified,
81+
'external_id' => $this->externalId,
82+
'last_sign_in_at' => $this->lastSignInAt?->format(\DateTimeInterface::RFC3339_EXTENDED),
83+
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
84+
'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED),
85+
'name' => $this->name,
86+
'metadata' => $this->metadata,
87+
'locale' => $this->locale,
2988
'radar_auth_attempt_id' => $this->radarAuthAttemptId,
3089
];
3190
}

lib/Service/UserManagement.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function getJwks(
6666
* @param string|null $ipAddress
6767
* @param string|null $deviceId
6868
* @param string|null $userAgent
69+
* @param string|null $signalsId
70+
* @param string|null $radarAuthAttemptId
6971
* @return \WorkOS\Resource\AuthenticateResponse
7072
* @throws \WorkOS\Exception\WorkOSException
7173
*/
@@ -76,6 +78,8 @@ public function authenticateWithPassword(
7678
?string $ipAddress = null,
7779
?string $deviceId = null,
7880
?string $userAgent = null,
81+
?string $signalsId = null,
82+
?string $radarAuthAttemptId = null,
7983
?\WorkOS\RequestOptions $options = null,
8084
): \WorkOS\Resource\AuthenticateResponse {
8185
$body = array_filter([
@@ -86,6 +90,8 @@ public function authenticateWithPassword(
8690
'ip_address' => $ipAddress,
8791
'device_id' => $deviceId,
8892
'user_agent' => $userAgent,
93+
'signals_id' => $signalsId,
94+
'radar_auth_attempt_id' => $radarAuthAttemptId,
8995
], fn ($v) => $v !== null);
9096
$body['client_id'] = $this->client->requireClientId();
9197
$body['client_secret'] = $this->client->requireApiKey();
@@ -106,6 +112,7 @@ public function authenticateWithPassword(
106112
* @param string|null $ipAddress
107113
* @param string|null $deviceId
108114
* @param string|null $userAgent
115+
* @param string|null $signalsId
109116
* @return \WorkOS\Resource\AuthenticateResponse
110117
* @throws \WorkOS\Exception\WorkOSException
111118
*/
@@ -116,6 +123,7 @@ public function authenticateWithCode(
116123
?string $ipAddress = null,
117124
?string $deviceId = null,
118125
?string $userAgent = null,
126+
?string $signalsId = null,
119127
?\WorkOS\RequestOptions $options = null,
120128
): \WorkOS\Resource\AuthenticateResponse {
121129
$body = array_filter([
@@ -126,6 +134,7 @@ public function authenticateWithCode(
126134
'ip_address' => $ipAddress,
127135
'device_id' => $deviceId,
128136
'user_agent' => $userAgent,
137+
'signals_id' => $signalsId,
129138
], fn ($v) => $v !== null);
130139
$body['client_id'] = $this->client->requireClientId();
131140
$body['client_secret'] = $this->client->requireApiKey();
@@ -183,6 +192,7 @@ public function authenticateWithRefreshToken(
183192
* @param string|null $ipAddress
184193
* @param string|null $deviceId
185194
* @param string|null $userAgent
195+
* @param string|null $radarAuthAttemptId
186196
* @return \WorkOS\Resource\AuthenticateResponse
187197
* @throws \WorkOS\Exception\WorkOSException
188198
*/
@@ -193,6 +203,7 @@ public function authenticateWithMagicAuth(
193203
?string $ipAddress = null,
194204
?string $deviceId = null,
195205
?string $userAgent = null,
206+
?string $radarAuthAttemptId = null,
196207
?\WorkOS\RequestOptions $options = null,
197208
): \WorkOS\Resource\AuthenticateResponse {
198209
$body = array_filter([
@@ -203,6 +214,7 @@ public function authenticateWithMagicAuth(
203214
'ip_address' => $ipAddress,
204215
'device_id' => $deviceId,
205216
'user_agent' => $userAgent,
217+
'radar_auth_attempt_id' => $radarAuthAttemptId,
206218
], fn ($v) => $v !== null);
207219
$body['client_id'] = $this->client->requireClientId();
208220
$body['client_secret'] = $this->client->requireApiKey();
@@ -363,6 +375,89 @@ public function authenticateWithDeviceCode(
363375
return AuthenticateResponse::fromArray($response);
364376
}
365377

378+
/**
379+
* @param string $code
380+
* @param string $radarChallengeId
381+
* @param string $pendingAuthenticationToken
382+
* @param string|null $ipAddress
383+
* @param string|null $deviceId
384+
* @param string|null $userAgent
385+
* @return \WorkOS\Resource\AuthenticateResponse
386+
* @throws \WorkOS\Exception\WorkOSException
387+
*/
388+
public function authenticateWithRadarEmailChallenge(
389+
string $code,
390+
string $radarChallengeId,
391+
string $pendingAuthenticationToken,
392+
?string $ipAddress = null,
393+
?string $deviceId = null,
394+
?string $userAgent = null,
395+
?\WorkOS\RequestOptions $options = null,
396+
): \WorkOS\Resource\AuthenticateResponse {
397+
$body = array_filter([
398+
'grant_type' => 'urn:workos:oauth:grant-type:radar-email-challenge:code',
399+
'code' => $code,
400+
'radar_challenge_id' => $radarChallengeId,
401+
'pending_authentication_token' => $pendingAuthenticationToken,
402+
'ip_address' => $ipAddress,
403+
'device_id' => $deviceId,
404+
'user_agent' => $userAgent,
405+
], fn ($v) => $v !== null);
406+
$body['client_id'] = $this->client->requireClientId();
407+
$body['client_secret'] = $this->client->requireApiKey();
408+
409+
$response = $this->client->request(
410+
method: 'POST',
411+
path: 'user_management/authenticate',
412+
body: $body,
413+
options: $options,
414+
);
415+
return AuthenticateResponse::fromArray($response);
416+
}
417+
418+
/**
419+
* @param string $code
420+
* @param string $verificationId
421+
* @param string $phoneNumber
422+
* @param string $pendingAuthenticationToken
423+
* @param string|null $ipAddress
424+
* @param string|null $deviceId
425+
* @param string|null $userAgent
426+
* @return \WorkOS\Resource\AuthenticateResponse
427+
* @throws \WorkOS\Exception\WorkOSException
428+
*/
429+
public function authenticateWithRadarSmsChallenge(
430+
string $code,
431+
string $verificationId,
432+
string $phoneNumber,
433+
string $pendingAuthenticationToken,
434+
?string $ipAddress = null,
435+
?string $deviceId = null,
436+
?string $userAgent = null,
437+
?\WorkOS\RequestOptions $options = null,
438+
): \WorkOS\Resource\AuthenticateResponse {
439+
$body = array_filter([
440+
'grant_type' => 'urn:workos:oauth:grant-type:radar-sms-challenge:code',
441+
'code' => $code,
442+
'verification_id' => $verificationId,
443+
'phone_number' => $phoneNumber,
444+
'pending_authentication_token' => $pendingAuthenticationToken,
445+
'ip_address' => $ipAddress,
446+
'device_id' => $deviceId,
447+
'user_agent' => $userAgent,
448+
], fn ($v) => $v !== null);
449+
$body['client_id'] = $this->client->requireClientId();
450+
$body['client_secret'] = $this->client->requireApiKey();
451+
452+
$response = $this->client->request(
453+
method: 'POST',
454+
path: 'user_management/authenticate',
455+
body: $body,
456+
options: $options,
457+
);
458+
return AuthenticateResponse::fromArray($response);
459+
}
460+
366461
/**
367462
* Get an authorization URL
368463
*

tests/Fixtures/authenticate_response.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"id": "user_01E4ZCR3C56J083X43JQXF3JK5",
55
"first_name": "Marcelina",
66
"last_name": "Davis",
7+
"name": "Marcelina Davis",
78
"profile_picture_url": "https://workoscdn.com/images/v1/123abc",
89
"email": "marcelina.davis@example.com",
910
"email_verified": true,
@@ -14,8 +15,7 @@
1415
"last_sign_in_at": "2025-06-25T19:07:33.155Z",
1516
"locale": "en-US",
1617
"created_at": "2026-01-15T12:00:00.000Z",
17-
"updated_at": "2026-01-15T12:00:00.000Z",
18-
"name": "Marcelina Davis"
18+
"updated_at": "2026-01-15T12:00:00.000Z"
1919
},
2020
"organization_id": "org_01H945H0YD4F97JN9MATX7BYAG",
2121
"authkit_authorization_code": "authkit_authz_code_abc123",

tests/Fixtures/authorization_code_session_authenticate_request.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"client_secret": "sk_test_....",
44
"grant_type": "authorization_code",
55
"code": "vBqZKaPpsnJlPfXiDqN7b6VTz",
6+
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
7+
"invitation_token": "inv_tok_01HXYZ123456789ABCDEFGHIJ",
68
"ip_address": "203.0.113.42",
79
"device_id": "device_01HXYZ123456789ABCDEFGHIJ",
810
"user_agent": "Mozilla/5.0",
9-
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
10-
"invitation_token": "inv_tok_01HXYZ123456789ABCDEFGHIJ",
1111
"signals_id": "01JBS0GN92GC2RJQS4X9DBPQ2A"
1212
}

tests/Fixtures/authorized_connect_application_list_data.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"profile",
77
"email"
88
],
9+
"oauth_resource": "https://api.example.com/resource",
910
"application": {
1011
"object": "connect_application",
1112
"id": "conn_app_01HXYZ123456789ABCDEFGHIJ",
@@ -18,9 +19,6 @@
1819
"email"
1920
],
2021
"created_at": "2026-01-15T12:00:00.000Z",
21-
"updated_at": "2026-01-15T12:00:00.000Z",
22-
"application_type": "m2m",
23-
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
24-
},
25-
"oauth_resource": "https://api.example.com/resource"
22+
"updated_at": "2026-01-15T12:00:00.000Z"
23+
}
2624
}

tests/Fixtures/connect_application.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
"email"
1111
],
1212
"created_at": "2026-01-15T12:00:00.000Z",
13-
"updated_at": "2026-01-15T12:00:00.000Z",
14-
"application_type": "m2m",
15-
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
13+
"updated_at": "2026-01-15T12:00:00.000Z"
1614
}

0 commit comments

Comments
 (0)