Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): remove devFeature guard #6462

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/sso-connectors": {
"get": {
"tags": ["Dev feature"],
"summary": "Get all the enabled SSO connectors by the given email's domain",
"description": "Extract the email domain from the provided email address. Returns all the enabled SSO connectors that match the email domain.",
"parameters": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
// Sync social/enterprise SSO identity profile data.
// Note: The profile data is not saved to the user profile until the user submits the interaction.
// Also no need to validate the synced profile data availability as it is already validated during the identification process.
if (syncedProfile) {
if (syncedProfile && Object.keys(syncedProfile).length > 0) {

Check warning on line 238 in packages/core/src/routes/experience/classes/experience-interaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/classes/experience-interaction.ts#L238

Added line #L238 was not covered by tests
const log = this.ctx.createLog(`Interaction.${this.interactionEvent}.Profile.Update`);
log.append({ syncedProfile });
this.profile.unsafeSet(syncedProfile);
Expand Down Expand Up @@ -362,7 +362,7 @@
);

// Prepend the interaction data to all log entries
this.ctx.prependAllLogEntries({ interaction: interactionData });
this.ctx.prependAllLogEntries({ interaction: interactionData, userId: this.userId });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
{
"name": "Experience",
"description": "The Experience endpoints allow end-users to interact with Logto for identity verification and profile completion."
},
{ "name": "Dev feature" }
}
],
"paths": {
"/api/experience": {
"put": {
"tags": ["Dev feature"],
"summary": "Init a new experience interaction",
"description": "Init a new experience interaction with the given interaction type. Any existing experience interaction data will be cleared.",
"responses": {
Expand All @@ -21,7 +19,6 @@
},
"/api/experience/interaction-event": {
"put": {
"tags": ["Dev feature"],
"summary": "Update current experience interaction event",
"description": "Update the current experience interaction event to the given event type. This API is used to switch the interaction event between `SignIn` and `Register`, while keeping all the verification records data.",
"requestBody": {
Expand Down Expand Up @@ -52,7 +49,6 @@
},
"/api/experience/identification": {
"post": {
"tags": ["Dev feature"],
"summary": "Identify the user within the current experience interaction using the provided verification data",
"description": "This API identifies the user based on the verificationId within the current experience interaction: <br/>- `SignIn` and `ForgotPassword` interactions: Verifies the user's identity using the provided `verificationId`. <br/>- `Register` interaction: Creates a new user account using the profile data from the current interaction. If a verificationId is provided, the profile data will first be updated with the verification record before creating the account. If not, the account is created directly from the stored profile data.",
"requestBody": {
Expand Down Expand Up @@ -101,7 +97,6 @@
},
"/api/experience/submit": {
"post": {
"tags": ["Dev feature"],
"summary": "Submit experience interaction",
"description": "Submit the current interaction. <br/>- Submit the verified user identity to the OIDC provider for further authentication (SignIn and Register). <br/>- Update the user's profile data if any (SignIn and Register). <br/>- Reset the password and clear all the interaction records (ForgotPassword).",
"responses": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/routes/experience/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@

log.append({
interaction: ctx.experienceInteraction.toJson(),
userId: ctx.experienceInteraction.identifiedUserId,

Check warning on line 174 in packages/core/src/routes/experience/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/index.ts#L174

Added line #L174 was not covered by tests
});

ctx.status = 200;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
if (ctx.experienceInteraction) {
ctx.prependAllLogEntries({
interaction: ctx.experienceInteraction.toJson(),
userId: ctx.experienceInteraction.identifiedUserId,

Check warning on line 68 in packages/core/src/routes/experience/middleware/koa-experience-interaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/middleware/koa-experience-interaction.ts#L68

Added line #L68 was not covered by tests
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/profile": {
"post": {
"tags": ["Dev feature"],
"summary": "Fulfill user profile data",
"description": "Adds user profile data to the current experience interaction. <br/>- For `Register`: The profile data provided before the identification request will be used to create a new user account. <br/>- For `SignIn` and `Register`: The profile data provided after the user is identified will be used to update the user's profile when the interaction is submitted. <br/>- `ForgotPassword`: Not supported.",
"requestBody": {
Expand Down Expand Up @@ -45,7 +44,6 @@
},
"/api/experience/profile/password": {
"put": {
"tags": ["Dev feature"],
"summary": "Reset user password",
"description": "Update the user's password. (`ForgotPassword` interaction only)",
"requestBody": {
Expand Down Expand Up @@ -79,7 +77,6 @@
},
"/api/experience/profile/mfa/mfa-skipped": {
"post": {
"tags": ["Dev feature"],
"summary": "Skip Multi-Factor Authentication (MFA) binding flow",
"description": "Skip MFA verification binding flow. If the MFA is enabled in the sign-in experience settings and marked as `UserControlled`, the user can skip the MFA verification binding flow by calling this API.",
"responses": {
Expand All @@ -103,7 +100,6 @@
},
"/api/experience/profile/mfa": {
"post": {
"tags": ["Dev feature"],
"summary": "Bind Multi-Factor Authentication (MFA) verification by verificationId",
"description": "Bind new MFA verification to the user profile using the verificationId.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/backup-code/generate": {
"post": {
"tags": ["Dev feature"],
"summary": "Generate backup codes",
"description": "Generate backup codes for the current user. A new BackupCode verification record will be created in the current interaction.",
"responses": {
Expand Down Expand Up @@ -31,7 +30,6 @@
},
"/api/experience/verification/backup-code/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify backup code",
"description": "Verify the provided backup code against the user's backup codes. A new BackupCode verification record will be created and marked as verified if the code is correct.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/sso/{connectorId}/authorization-uri": {
"post": {
"tags": ["Dev feature"],
"summary": "Get SSO authorization URI",
"description": "Create a new EnterpriseSSO verification record and return the authorization URI for the given connector.",
"requestBody": {
Expand Down Expand Up @@ -50,7 +49,6 @@
},
"/api/experience/verification/sso/{connectorId}/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify SSO authorization response",
"description": "Verify the SSO authorization response data and get the user's profile data from the SSO connector.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/new-password-identity": {
"post": {
"tags": ["Dev feature"],
"summary": "Create a new password identity for new user registration use",
"description": "Create a NewPasswordIdentity verification record for the new user registration use. The verification record includes a unique user identifier and a password that can be used to verify the user's identity.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/password": {
"post": {
"tags": ["Dev feature"],
"summary": "Create and verify a new password verification record",
"description": "Generate a new Password verification record, which can be used to identify the user through the `Identification` API.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/social/{connectorId}/authorization-uri": {
"post": {
"tags": ["Dev feature"],
"summary": "Get social authorization URI",
"description": "Create a new SocialVerification record and return the authorization URI for the given connector.",
"requestBody": {
Expand Down Expand Up @@ -50,7 +49,6 @@
},
"/api/experience/verification/social/{connectorId}/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify social authorization response",
"description": "Verify the social authorization response data and get the user's profile data from the social connector.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/totp/secret": {
"post": {
"tags": ["Dev feature"],
"summary": "Generate TOTP secret for new TOTP binding",
"description": "Creates a new TOTP secret for the user to bind a new TOTP verification to their account.",
"responses": {
Expand Down Expand Up @@ -34,7 +33,6 @@
},
"/api/experience/verification/totp/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify TOTP code",
"description": "Verifies the provided TOTP code against the user's TOTP secret. If the code is correct, a new TOTP verification record will be created and marked as verified..",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/verification-code": {
"post": {
"tags": ["Dev feature"],
"summary": "Create and send verification code",
"description": "Creates a new `CodeVerification` record and sends the code to the specified identifier. The code verification can be used to verify the user's identity or bind a new identifier to the user's account.",
"requestBody": {
Expand Down Expand Up @@ -47,7 +46,6 @@
},
"/api/experience/verification/verification-code/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify verification code",
"description": "Verifies the provided verification code against the user's identifier. If successful, the verification record is marked as verified.",
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"paths": {
"/api/experience/verification/web-authn/registration": {
"post": {
"tags": ["Dev feature"],
"summary": "Create WebAuthn registration",
"description": "Creates a new WebAuthn registration verification record to allow the user to bind a new WebAuthn credential to their account.",
"responses": {
Expand Down Expand Up @@ -31,7 +30,6 @@
},
"/api/experience/verification/web-authn/registration/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify WebAuthn registration",
"description": "Verifies the WebAuthn registration response against the user's WebAuthn registration challenge. If the response is valid, the WebAuthn registration record will be marked as verified.",
"requestBody": {
Expand Down Expand Up @@ -76,7 +74,6 @@
},
"/api/experience/verification/web-authn/authentication": {
"post": {
"tags": ["Dev feature"],
"summary": "Initiate WebAuthn authentication",
"description": "Creates a new WebAuthn authentication verification record, allowing the user to authenticate with their WebAuthn credential.",
"responses": {
Expand Down Expand Up @@ -108,7 +105,6 @@
},
"/api/experience/verification/web-authn/authentication/verify": {
"post": {
"tags": ["Dev feature"],
"summary": "Verify WebAuthn authentication",
"description": "Verifies the WebAuthn authentication response against the user's authentication challenge. Upon successful verification, the WebAuthn authentication verification record will be marked as verified.",
"requestBody": {
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/routes/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@
interactionRoutes(interactionRouter, tenant);

const experienceRouter: AnonymousRouter = new Router();
if (EnvSet.values.isDevFeaturesEnabled) {
experienceRouter.use(koaAuditLog(tenant.queries));
experienceApiRoutes(experienceRouter, tenant);
}
experienceRouter.use(koaAuditLog(tenant.queries));
experienceApiRoutes(experienceRouter, tenant);

const managementRouter: ManagementApiRouter = new Router();
managementRouter.use(koaAuth(tenant.envSet, getManagementApiResourceIndicator(tenant.id)));
managementRouter.use(koaTenantGuard(tenant.id, tenant.queries));
managementRouter.use(koaManagementApiHooks(tenant.libraries.hooks));

// TODO: FIXME @sijie @darcy mount these routes in `applicationRoutes` instead

Check warning on line 65 in packages/core/src/routes/init.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/core/src/routes/init.ts#L65

[no-warning-comments] Unexpected 'todo' comment: 'TODO: FIXME @sijie @darcy mount these...'.
applicationRoutes(managementRouter, tenant);
applicationRoleRoutes(managementRouter, tenant);
applicationProtectedAppMetadataRoutes(managementRouter, tenant);
Expand Down Expand Up @@ -112,7 +110,7 @@
managementRouter,
anonymousRouter,
experienceRouter,
// TODO: interactionRouter should be removed from swagger.json

Check warning on line 113 in packages/core/src/routes/init.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/core/src/routes/init.ts#L113

[no-warning-comments] Unexpected 'todo' comment: 'TODO: interactionRouter should be...'.
interactionRouter,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import {
enableUserControlledMfaWithTotp,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest } from '#src/utils.js';

devFeatureTest.describe('Bind MFA APIs happy path', () => {
describe('Bind MFA APIs happy path', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
enableMandatoryMfaWithTotpAndBackupCode,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest } from '#src/utils.js';

devFeatureTest.describe('Bind MFA APIs sad path', () => {
describe('Bind MFA APIs sad path', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { InteractionEvent, SignInIdentifier } from '@logto/schemas';
import { initExperienceClient } from '#src/helpers/client.js';
import { expectRejects } from '#src/helpers/index.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest } from '#src/utils.js';

devFeatureTest.describe('PUT /experience API', () => {
describe('PUT /experience API', () => {
const userApi = new UserApiTest();

afterAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
resetMfaSettings,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest, generateEmail } from '#src/utils.js';
import { generateEmail } from '#src/utils.js';

devFeatureTest.describe('Fulfill User Profiles', () => {
describe('Fulfill User Profiles', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { expectRejects } from '#src/helpers/index.js';
import { enableAllPasswordSignInMethods } from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest, generatePassword } from '#src/utils.js';
import { generatePassword } from '#src/utils.js';

const identifyForgotPasswordInteraction = async (client: ExperienceClient, email: string) => {
const { verificationId, code } = await successfullySendVerificationCode(client, {
Expand All @@ -27,7 +27,7 @@ const identifyForgotPasswordInteraction = async (client: ExperienceClient, email
await client.identifyUser({ verificationId });
};

devFeatureTest.describe('Reset Password', () => {
describe('Reset Password', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from '#src/helpers/experience/index.js';
import { OrganizationApiTest } from '#src/helpers/organization.js';
import { enableAllVerificationCodeSignInMethods } from '#src/helpers/sign-in-experience.js';
import { devFeatureTest, generateEmail, randomString } from '#src/utils.js';
import { generateEmail, randomString } from '#src/utils.js';

devFeatureTest.describe('organization just-in-time provisioning', () => {
describe('organization just-in-time provisioning', () => {
const organizationApi = new OrganizationApiTest();
const ssoConnectorApi = new SsoConnectorApi();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '#src/helpers/experience/index.js';
import { expectRejects } from '#src/helpers/index.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest, generateUsername } from '#src/utils.js';
import { generateUsername } from '#src/utils.js';

devFeatureTest.describe('register new user with username and password', () => {
describe('register new user with username and password', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { expectRejects } from '#src/helpers/index.js';
import { enableAllVerificationCodeSignInMethods } from '#src/helpers/sign-in-experience.js';
import { generateNewUser } from '#src/helpers/user.js';
import { devFeatureTest, generateEmail, generatePhone } from '#src/utils.js';
import { generateEmail, generatePhone } from '#src/utils.js';

const verificationIdentifierType: readonly [SignInIdentifier.Email, SignInIdentifier.Phone] =
Object.freeze([SignInIdentifier.Email, SignInIdentifier.Phone]);
Expand All @@ -25,7 +25,7 @@ const identifiersTypeToUserProfile = Object.freeze({
phone: 'primaryPhone',
});

devFeatureTest.describe('Register interaction with verification code happy path', () => {
describe('Register interaction with verification code happy path', () => {
beforeAll(async () => {
await Promise.all([setEmailConnector(), setSmsConnector()]);
await enableAllVerificationCodeSignInMethods({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
enableMandatoryMfaWithTotp,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUser, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest, generateEmail, generatePassword } from '#src/utils.js';
import { generateEmail, generatePassword } from '#src/utils.js';

devFeatureTest.describe('enterprise sso sign-in and sign-up', () => {
describe('enterprise sso sign-in and sign-up', () => {
const ssoConnectorApi = new SsoConnectorApi();
const domain = 'foo.com';
const enterpriseSsoIdentityId = generateStandardId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
enableMandatoryMfaWithTotpAndBackupCode,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, UserApiTest } from '#src/helpers/user.js';
import { devFeatureTest } from '#src/utils.js';

devFeatureTest.describe('mfa sign-in verification', () => {
describe('mfa sign-in verification', () => {
const userApi = new UserApiTest();

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import {
enableAllVerificationCodeSignInMethods,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUser } from '#src/helpers/user.js';
import { devFeatureTest, generateEmail } from '#src/utils.js';
import { generateEmail } from '#src/utils.js';

const identifiersTypeToUserProfile = Object.freeze({
username: 'username',
email: 'primaryEmail',
phone: 'primaryPhone',
});

devFeatureTest.describe('sign-in with password verification happy path', () => {
describe('sign-in with password verification happy path', () => {
beforeAll(async () => {
await enableAllPasswordSignInMethods();
await Promise.all([setEmailConnector(), setSmsConnector()]);
Expand Down
Loading
Loading