Skip to content

Commit 3992acd

Browse files
wied03hjaretspwitt
authored
Merge feature/ENG-1111/mfa-lambda (#211)
* first lambda type * reduce client blast radius (#204) * MFA lambda configuration (#205) * ENG-3487: Tenant-scoped IdPs (#202) * update domain for tenantId on IdPs (#199) * add tenantId to IdP lookup by managed domain response (#201) * Merge wied03/ENG-3602/mfa-lambda-invocation (#206) * propagate client changes * client code update from Javadoc * Merge wied03/ENG-3603/mfa-retrieve-status-post (#207) * propagate client changes * client code update from Javadoc * client generation/new method * better method name * missing client stuff * redo client again * Merge wied03/ENG-3608/mfa-change-password (#210) * add IP address client overload * forgot to update method names * naming advice * mfa lambda * Change function name and parameters * PR feedback - lambda classses - new package and names * keep value as mfaTrust within lambda * pass raw JWT all the way in * Lambda signature - registration out of context, action and app in * Change context.encodedJWT to context.accessToken * rename token to accessToken on status API --------- Co-authored-by: Jaret Hendrickson <jaret.hendrickson+github@fusionauth.io> Co-authored-by: Spencer Witt <3409780+spwitt@users.noreply.github.com> Co-authored-by: Jaret Hendrickson <jaret.hendrickson@fusionauth.io>
1 parent 2f7373d commit 3992acd

File tree

1 file changed

+175
-1
lines changed

1 file changed

+175
-1
lines changed

src/FusionAuthClient.ts

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,26 @@ export class FusionAuthClient {
232232
.go();
233233
}
234234

235+
/**
236+
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
237+
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
238+
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
239+
*
240+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
241+
*
242+
* @param {string} changePasswordId The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated.
243+
* @param {string} ipAddress (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
244+
* @returns {Promise<ClientResponse<void>>}
245+
*/
246+
checkChangePasswordUsingIdAndIPAddress(changePasswordId: string, ipAddress: string): Promise<ClientResponse<void>> {
247+
return this.startAnonymous<void, Errors>()
248+
.withUri('/api/user/change-password')
249+
.withUriSegment(changePasswordId)
250+
.withParameter('ipAddress', ipAddress)
251+
.withMethod("GET")
252+
.go();
253+
}
254+
235255
/**
236256
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
237257
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
@@ -250,6 +270,26 @@ export class FusionAuthClient {
250270
.go();
251271
}
252272

273+
/**
274+
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
275+
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
276+
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
277+
*
278+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
279+
*
280+
* @param {string} encodedJWT The encoded JWT (access token).
281+
* @param {string} ipAddress (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
282+
* @returns {Promise<ClientResponse<void>>}
283+
*/
284+
checkChangePasswordUsingJWTAndIPAddress(encodedJWT: string, ipAddress: string): Promise<ClientResponse<void>> {
285+
return this.startAnonymous<void, Errors>()
286+
.withUri('/api/user/change-password')
287+
.withAuthorization('Bearer ' + encodedJWT)
288+
.withParameter('ipAddress', ipAddress)
289+
.withMethod("GET")
290+
.go();
291+
}
292+
253293
/**
254294
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
255295
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
@@ -268,6 +308,26 @@ export class FusionAuthClient {
268308
.go();
269309
}
270310

311+
/**
312+
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
313+
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
314+
* your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
315+
*
316+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
317+
*
318+
* @param {string} loginId The loginId (email or username) of the User that you intend to change the password for.
319+
* @param {string} ipAddress (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
320+
* @returns {Promise<ClientResponse<void>>}
321+
*/
322+
checkChangePasswordUsingLoginIdAndIPAddress(loginId: string, ipAddress: string): Promise<ClientResponse<void>> {
323+
return this.start<void, Errors>()
324+
.withUri('/api/user/change-password')
325+
.withParameter('loginId', loginId)
326+
.withParameter('ipAddress', ipAddress)
327+
.withMethod("GET")
328+
.go();
329+
}
330+
271331
/**
272332
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
273333
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
@@ -288,6 +348,28 @@ export class FusionAuthClient {
288348
.go();
289349
}
290350

351+
/**
352+
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
353+
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
354+
* your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
355+
*
356+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
357+
*
358+
* @param {string} loginId The loginId of the User that you intend to change the password for.
359+
* @param {Array<String>} loginIdTypes The identity types that FusionAuth will compare the loginId to.
360+
* @param {string} ipAddress (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
361+
* @returns {Promise<ClientResponse<void>>}
362+
*/
363+
checkChangePasswordUsingLoginIdAndLoginIdTypesAndIPAddress(loginId: string, loginIdTypes: Array<String>, ipAddress: string): Promise<ClientResponse<void>> {
364+
return this.start<void, Errors>()
365+
.withUri('/api/user/change-password')
366+
.withParameter('loginId', loginId)
367+
.withParameter('loginIdTypes', loginIdTypes)
368+
.withParameter('ipAddress', ipAddress)
369+
.withMethod("GET")
370+
.go();
371+
}
372+
291373
/**
292374
* Make a Client Credentials grant request to obtain an access token.
293375
*
@@ -3853,6 +3935,24 @@ export class FusionAuthClient {
38533935
.go();
38543936
}
38553937

3938+
/**
3939+
* Retrieve a user's two-factor status.
3940+
*
3941+
* This can be used to see if a user will need to complete a two-factor challenge to complete a login,
3942+
* and optionally identify the state of the two-factor trust across various applications. This operation
3943+
* provides more payload options than retrieveTwoFactorStatus.
3944+
*
3945+
* @param {TwoFactorStatusRequest} request The request object that contains all the information used to check the status.
3946+
* @returns {Promise<ClientResponse<TwoFactorStatusResponse>>}
3947+
*/
3948+
retrieveTwoFactorStatusWithRequest(request: TwoFactorStatusRequest): Promise<ClientResponse<TwoFactorStatusResponse>> {
3949+
return this.start<TwoFactorStatusResponse, Errors>()
3950+
.withUri('/api/two-factor/status')
3951+
.withJSONBody(request)
3952+
.withMethod("POST")
3953+
.go();
3954+
}
3955+
38563956
/**
38573957
* Retrieves the user for the given Id.
38583958
*
@@ -5974,6 +6074,7 @@ export interface AuthenticationTokenConfiguration extends Enableable {
59746074
export interface LambdaConfiguration {
59756075
accessTokenPopulateId?: UUID;
59766076
idTokenPopulateId?: UUID;
6077+
multiFactorRequirementId?: UUID;
59776078
samlv2PopulateId?: UUID;
59786079
selfServiceRegistrationValidationId?: UUID;
59796080
userinfoPopulateId?: UUID;
@@ -6840,6 +6941,19 @@ export enum ContentStatus {
68406941
REJECTED = "REJECTED"
68416942
}
68426943

6944+
/**
6945+
* Represents the inbound lambda parameter 'context' for MFA Required lambdas.
6946+
*/
6947+
export interface Context {
6948+
accessToken?: string;
6949+
action?: MultiFactorAction;
6950+
application?: Application;
6951+
authenticationThreats?: Array<AuthenticationThreats>;
6952+
eventInfo?: EventInfo;
6953+
mfaTrust?: Trust;
6954+
policies?: Policies;
6955+
}
6956+
68436957
/**
68446958
* A number identifying a cryptographic algorithm. Values should be registered with the <a
68456959
* href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">IANA COSE Algorithms registry</a>
@@ -9067,7 +9181,8 @@ export enum LambdaType {
90679181
SCIMServerUserResponseConverter = "SCIMServerUserResponseConverter",
90689182
SelfServiceRegistrationValidation = "SelfServiceRegistrationValidation",
90699183
UserInfoPopulate = "UserInfoPopulate",
9070-
LoginValidation = "LoginValidation"
9184+
LoginValidation = "LoginValidation",
9185+
MFARequirement = "MFARequirement"
90719186
}
90729187

90739188
/**
@@ -9426,6 +9541,15 @@ export interface MonthlyActiveUserReportResponse {
94269541
total?: number;
94279542
}
94289543

9544+
/**
9545+
* Communicate various actions/contexts in which multi-factor authentication can be used.
9546+
*/
9547+
export enum MultiFactorAction {
9548+
changePassword = "changePassword",
9549+
login = "login",
9550+
stepUp = "stepUp"
9551+
}
9552+
94299553
/**
94309554
* @author Daniel DeGroff
94319555
*/
@@ -9871,6 +9995,15 @@ export interface PhoneUnverifiedOptions {
98719995
behavior?: UnverifiedBehavior;
98729996
}
98739997

9998+
/**
9999+
* Represents the inbound lambda parameter 'policies' for MFA Required lambdas.
10000+
*/
10001+
export interface Policies {
10002+
applicationLoginPolicy?: MultiFactorLoginPolicy;
10003+
applicationMultiFactorTrustPolicy?: ApplicationMultiFactorTrustPolicy;
10004+
tenantLoginPolicy?: MultiFactorLoginPolicy;
10005+
}
10006+
987410007
/**
987510008
* @author Michael Sleevi
987610009
*/
@@ -10101,6 +10234,7 @@ export interface ReactorStatus {
1010110234
expiration?: string;
1010210235
licenseAttributes?: Record<string, string>;
1010310236
licensed?: boolean;
10237+
multiFactorLambdas?: ReactorFeatureStatus;
1010410238
scimServer?: ReactorFeatureStatus;
1010510239
tenantManagerApplication?: ReactorFeatureStatus;
1010610240
threatDetection?: ReactorFeatureStatus;
@@ -10322,6 +10456,14 @@ export interface Requirable extends Enableable {
1032210456
required?: boolean;
1032310457
}
1032410458

10459+
/**
10460+
* Represents the inbound lambda parameter 'result' for MFA Required lambdas.
10461+
*/
10462+
export interface RequiredLambdaResult {
10463+
required?: boolean;
10464+
sendSuspiciousLoginEvent?: boolean;
10465+
}
10466+
1032510467
/**
1032610468
* Interface describing the need for CORS configuration.
1032710469
*
@@ -10874,6 +11016,7 @@ export interface TenantFormConfiguration {
1087411016
*/
1087511017
export interface TenantLambdaConfiguration {
1087611018
loginValidationId?: UUID;
11019+
multiFactorRequirementId?: UUID;
1087711020
scimEnterpriseUserRequestConverterId?: UUID;
1087811021
scimEnterpriseUserResponseConverterId?: UUID;
1087911022
scimGroupRequestConverterId?: UUID;
@@ -11275,6 +11418,26 @@ export enum TransactionType {
1127511418
AbsoluteMajority = "AbsoluteMajority"
1127611419
}
1127711420

11421+
/**
11422+
* Represents the inbound lambda parameter 'mfaTrust' inside the 'context' parameter for MFA Required lambdas.
11423+
*/
11424+
export interface Trust {
11425+
applicationId?: UUID;
11426+
attributes?: Record<string, string>;
11427+
expirationInstant?: number;
11428+
id?: string;
11429+
insertInstant?: number;
11430+
startInstants?: StartInstant;
11431+
state?: Record<string, any>;
11432+
tenantId?: UUID;
11433+
userId?: UUID;
11434+
}
11435+
11436+
export interface StartInstant {
11437+
applications?: Record<UUID, number>;
11438+
tenant?: number;
11439+
}
11440+
1127811441
/**
1127911442
* @author Brett Guy
1128011443
*/
@@ -11434,6 +11597,17 @@ export interface TwoFactorStartResponse {
1143411597
twoFactorId?: string;
1143511598
}
1143611599

11600+
/**
11601+
* Check the status of two-factor authentication for a user, with more options than on a GET request.
11602+
*/
11603+
export interface TwoFactorStatusRequest extends BaseEventRequest {
11604+
accessToken?: string;
11605+
action?: MultiFactorAction;
11606+
applicationId?: UUID;
11607+
twoFactorTrustId?: string;
11608+
userId?: UUID;
11609+
}
11610+
1143711611
/**
1143811612
* @author Daniel DeGroff
1143911613
*/

0 commit comments

Comments
 (0)