Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: adds support for last logged in auth method field

=4dcd3ed06c21
diff --git a/backend/src/db/migrations/20250805151349_last-logged-auth-method.ts b/backend/src/db/migrations/20250805151349_last-logged-auth-method.ts
new file mode 100644
index 0000000000..f321299065
--- /dev/null
+++ b/backend/src/db/migrations/20250805151349_last-logged-auth-method.ts
@@ -0,0 +1,41 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const lastUserLoggedInAuthMethod = await knex.schema.hasColumn(TableName.OrgMembership, "lastLoggedInAuthMethod");
+ const lastIdentityLoggedInAuthMethod = await knex.schema.hasColumn(
+ TableName.IdentityOrgMembership,
+ "lastLoggedInAuthMethod"
+ );
+ if (!lastUserLoggedInAuthMethod) {
+ await knex.schema.alterTable(TableName.OrgMembership, (t) => {
+ t.string("lastLoggedInAuthMethod").nullable();
+ });
+ }
+
+ if (!lastIdentityLoggedInAuthMethod) {
+ await knex.schema.alterTable(TableName.IdentityOrgMembership, (t) => {
+ t.string("lastLoggedInAuthMethod").nullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const lastUserLoggedInAuthMethod = await knex.schema.hasColumn(TableName.OrgMembership, "lastLoggedInAuthMethod");
+ const lastIdentityLoggedInAuthMethod = await knex.schema.hasColumn(
+ TableName.IdentityOrgMembership,
+ "lastLoggedInAuthMethod"
+ );
+ if (!lastUserLoggedInAuthMethod) {
+ await knex.schema.alterTable(TableName.OrgMembership, (t) => {
+ t.dropColumn("lastLoggedInAuthMethod");
+ });
+ }
+
+ if (!lastIdentityLoggedInAuthMethod) {
+ await knex.schema.alterTable(TableName.IdentityOrgMembership, (t) => {
+ t.dropColumn("lastLoggedInAuthMethod");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/identity-org-memberships.ts b/backend/src/db/schemas/identity-org-memberships.ts
index 2f29c52e43..2f0c81a3a2 100644
--- a/backend/src/db/schemas/identity-org-memberships.ts
+++ b/backend/src/db/schemas/identity-org-memberships.ts
@@ -14,7 +14,8 @@ export const IdentityOrgMembershipsSchema = z.object({
orgId: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
- identityId: z.string().uuid()
+ identityId: z.string().uuid(),
+ lastLoggedInAuthMethod: z.string().nullable().optional()
});
export type TIdentityOrgMemberships = z.infer<typeof IdentityOrgMembershipsSchema>;
diff --git a/backend/src/db/schemas/org-memberships.ts b/backend/src/db/schemas/org-memberships.ts
index 939033c71d..5be83be004 100644
--- a/backend/src/db/schemas/org-memberships.ts
+++ b/backend/src/db/schemas/org-memberships.ts
@@ -19,7 +19,8 @@ export const OrgMembershipsSchema = z.object({
roleId: z.string().uuid().nullable().optional(),
projectFavorites: z.string().array().nullable().optional(),
isActive: z.boolean().default(true),
- lastInvitedAt: z.date().nullable().optional()
+ lastInvitedAt: z.date().nullable().optional(),
+ lastLoggedInAuthMethod: z.string().nullable().optional()
});
export type TOrgMemberships = z.infer<typeof OrgMembershipsSchema>;
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 7dd1d3aa44..4d6830834c 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -148,9 +148,12 @@ export const authLoginServiceFactory = ({
if (organizationId) {
const org = await orgDAL.findById(organizationId);
- if (org && org.userTokenExpiration) {
- tokenSessionExpiresIn = getMinExpiresIn(cfg.JWT_AUTH_LIFETIME, org.userTokenExpiration);
- refreshTokenExpiresIn = org.userTokenExpiration;
+ if (org) {
+ await orgMembershipDAL.update({ userId: user.id, orgId: org.id }, { lastLoggedInAuthMethod: authMethod });
+ if (org.userTokenExpiration) {
+ tokenSessionExpiresIn = getMinExpiresIn(cfg.JWT_AUTH_LIFETIME, org.userTokenExpiration);
+ refreshTokenExpiresIn = org.userTokenExpiration;
+ }
}
}
diff --git a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
index 819329a221..fe77aa2c20 100644
--- a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
+++ b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
@@ -38,7 +38,7 @@ type TIdentityAliCloudAuthServiceFactoryDep = {
TIdentityAliCloudAuthDALFactory,
"findOne" | "transaction" | "create" | "updateById" | "delete"
>;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
};
@@ -87,6 +87,13 @@ export const identityAliCloudAuthServiceFactory = ({
// Generate the token
const identityAccessToken = await identityAliCloudAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.ALICLOUD_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityAliCloudAuth.identityId,
diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
index b5035946eb..3743934ed4 100644
--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
@@ -36,7 +36,7 @@ import {
type TIdentityAwsAuthServiceFactoryDep = {
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
identityAwsAuthDAL: Pick<TIdentityAwsAuthDALFactory, "findOne" | "transaction" | "create" | "updateById" | "delete">;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
};
@@ -152,6 +152,13 @@ export const identityAwsAuthServiceFactory = ({
}
const identityAccessToken = await identityAwsAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.AWS_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityAwsAuth.identityId,
diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
index 35103c8cf6..bbd9194b1b 100644
--- a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
@@ -33,7 +33,7 @@ type TIdentityAzureAuthServiceFactoryDep = {
TIdentityAzureAuthDALFactory,
"findOne" | "transaction" | "create" | "updateById" | "delete"
>;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -80,6 +80,13 @@ export const identityAzureAuthServiceFactory = ({
}
const identityAccessToken = await identityAzureAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.AZURE_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityAzureAuth.identityId,
diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
index b83697e526..09a3511ef0 100644
--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
@@ -31,7 +31,7 @@ import {
type TIdentityGcpAuthServiceFactoryDep = {
identityGcpAuthDAL: Pick<TIdentityGcpAuthDALFactory, "findOne" | "transaction" | "create" | "updateById" | "delete">;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -119,6 +119,13 @@ export const identityGcpAuthServiceFactory = ({
}
const identityAccessToken = await identityGcpAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.GCP_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityGcpAuth.identityId,
diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
index 35063ae708..3f0b1f5a59 100644
--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
@@ -43,7 +43,7 @@ import {
type TIdentityJwtAuthServiceFactoryDep = {
identityJwtAuthDAL: TIdentityJwtAuthDALFactory;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -209,6 +209,13 @@ export const identityJwtAuthServiceFactory = ({
}
const identityAccessToken = await identityJwtAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.JWT_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityJwtAuth.identityId,
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
index 41491ab2ff..2329285f0c 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
@@ -49,7 +49,7 @@ type TIdentityKubernetesAuthServiceFactoryDep = {
"create" | "findOne" | "transaction" | "updateById" | "delete"
>;
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "findById">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "findById" | "updateById">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
@@ -380,6 +380,13 @@ export const identityKubernetesAuthServiceFactory = ({
}
const identityAccessToken = await identityKubernetesAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.KUBERNETES_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityKubernetesAuth.identityId,
diff --git a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
index f38f53cf06..a94e93d111 100644
--- a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
+++ b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
@@ -44,7 +44,7 @@ type TIdentityLdapAuthServiceFactoryDep = {
TIdentityLdapAuthDALFactory,
"findOne" | "transaction" | "create" | "updateById" | "delete"
>;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
kmsService: TKmsServiceFactory;
@@ -144,6 +144,13 @@ export const identityLdapAuthServiceFactory = ({
}
const identityAccessToken = await identityLdapAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.LDAP_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityLdapAuth.identityId,
diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
index 3b6450e6e4..baaa5b4237 100644
--- a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
@@ -36,7 +36,7 @@ import {
type TIdentityOciAuthServiceFactoryDep = {
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
identityOciAuthDAL: Pick<TIdentityOciAuthDALFactory, "findOne" | "transaction" | "create" | "updateById" | "delete">;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
};
@@ -91,6 +91,13 @@ export const identityOciAuthServiceFactory = ({
// Generate the token
const identityAccessToken = await identityOciAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.OCI_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityOciAuth.identityId,
diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
index 08d53a344a..c7e0644284 100644
--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
@@ -43,7 +43,7 @@ import {
type TIdentityOidcAuthServiceFactoryDep = {
identityOidcAuthDAL: TIdentityOidcAuthDALFactory;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
identityAccessTokenDAL: Pick<TIdentityAccessTokenDALFactory, "create" | "delete">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -178,6 +178,13 @@ export const identityOidcAuthServiceFactory = ({
}
const identityAccessToken = await identityOidcAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.OIDC_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityOidcAuth.identityId,
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
index 742633b50d..b99de47a39 100644
--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
@@ -30,7 +30,7 @@ type TIdentityTlsCertAuthServiceFactoryDep = {
TIdentityTlsCertAuthDALFactory,
"findOne" | "transaction" | "create" | "updateById" | "delete"
>;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
@@ -118,6 +118,13 @@ export const identityTlsCertAuthServiceFactory = ({
// Generate the token
const identityAccessToken = await identityTlsCertAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.TLS_CERT_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityTlsCertAuth.identityId,
diff --git a/backend/src/services/identity-token-auth/identity-token-auth-service.ts b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
index 82949090e7..7903732ac0 100644
--- a/backend/src/services/identity-token-auth/identity-token-auth-service.ts
+++ b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
@@ -35,7 +35,7 @@ type TIdentityTokenAuthServiceFactoryDep = {
TIdentityTokenAuthDALFactory,
"transaction" | "create" | "findOne" | "updateById" | "delete"
>;
- identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne">;
+ identityOrgMembershipDAL: Pick<TIdentityOrgDALFactory, "findOne" | "updateById">;
identityAccessTokenDAL: Pick<
TIdentityAccessTokenDALFactory,
"create" | "find" | "update" | "findById" | "findOne" | "updateById" | "delete"
@@ -345,6 +345,13 @@ export const identityTokenAuthServiceFactory = ({
const identityTokenAuth = await identityTokenAuthDAL.findOne({ identityId });
const identityAccessToken = await identityTokenAuthDAL.transaction(async (tx) => {
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.TOKEN_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityTokenAuth.identityId,
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index cf5ccdeb7e..5732992e51 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -59,6 +59,11 @@ export const identityUaServiceFactory = ({
}
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId: identityUa.identityId });
+ if (!identityMembershipOrg) {
+ throw new NotFoundError({
+ message: "No identity with the org membership was found"
+ });
+ }
checkIPAgainstBlocklist({
ipAddress: ip,
@@ -127,7 +132,13 @@ export const identityUaServiceFactory = ({
const identityAccessToken = await identityUaDAL.transaction(async (tx) => {
const uaClientSecretDoc = await identityUaClientSecretDAL.incrementUsage(validClientSecretInfo!.id, tx);
-
+ await identityOrgMembershipDAL.updateById(
+ identityMembershipOrg.id,
+ {
+ lastLoggedInAuthMethod: IdentityAuthMethod.UNIVERSAL_AUTH
+ },
+ tx
+ );
const newToken = await identityAccessTokenDAL.create(
{
identityId: identityUa.identityId,
diff --git a/backend/src/services/identity/identity-org-dal.ts b/backend/src/services/identity/identity-org-dal.ts
index 3c5ca8ffe9..6dbf4be9b7 100644
--- a/backend/src/services/identity/identity-org-dal.ts
+++ b/backend/src/services/identity/identity-org-dal.ts
@@ -254,6 +254,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
db.ref("role").withSchema("paginatedIdentity"),
db.ref("roleId").withSchema("paginatedIdentity"),
db.ref("orgId").withSchema("paginatedIdentity"),
+ db.ref("lastLoggedInAuthMethod").withSchema("paginatedIdentity"),
db.ref("createdAt").withSchema("paginatedIdentity"),
db.ref("updatedAt").withSchema("paginatedIdentity"),
db.ref("identityId").withSchema("paginatedIdentity").as("identityId"),
@@ -319,7 +320,8 @@ export const identityOrgDALFactory = (db: TDbClient) => {
ldapId,
tlsCertId,
createdAt,
- updatedAt
+ updatedAt,
+ lastLoggedInAuthMethod
}) => ({
role,
roleId,
@@ -328,6 +330,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
orgId,
createdAt,
updatedAt,
+ lastLoggedInAuthMethod,
customRole: roleId
? {
id: crId,
@@ -497,6 +500,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
db.ref("orgId").withSchema(TableName.IdentityOrgMembership),
db.ref("createdAt").withSchema(TableName.IdentityOrgMembership),
db.ref("updatedAt").withSchema(TableName.IdentityOrgMembership),
+ db.ref("lastLoggedInAuthMethod").withSchema(TableName.IdentityOrgMembership),
db.ref("identityId").withSchema(TableName.IdentityOrgMembership).as("identityId"),
db.ref("name").withSchema(TableName.Identity).as("identityName"),
db.ref("hasDeleteProtection").withSchema(TableName.Identity),
@@ -576,7 +580,8 @@ export const identityOrgDALFactory = (db: TDbClient) => {
tokenId,
ldapId,
createdAt,
- updatedAt
+ updatedAt,
+ lastLoggedInAuthMethod
}) => ({
role,
roleId,
@@ -586,6 +591,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
orgId,
createdAt,
updatedAt,
+ lastLoggedInAuthMethod,
customRole: roleId
? {
id: crId,
diff --git a/backend/src/services/org-membership/org-membership-dal.ts b/backend/src/services/org-membership/org-membership-dal.ts
index ed4867025d..98e89c8329 100644
--- a/backend/src/services/org-membership/org-membership-dal.ts
+++ b/backend/src/services/org-membership/org-membership-dal.ts
@@ -32,6 +32,7 @@ export const orgMembershipDALFactory = (db: TDbClient) => {
db.ref("roleId").withSchema(TableName.OrgMembership),
db.ref("status").withSchema(TableName.OrgMembership),
db.ref("isActive").withSchema(TableName.OrgMembership),
+ db.ref("lastLoggedInAuthMethod").withSchema(TableName.OrgMembership),
db.ref("email").withSchema(TableName.Users),
db.ref("username").withSchema(TableName.Users),
db.ref("firstName").withSchema(TableName.Users),
@@ -64,7 +65,8 @@ export const orgMembershipDALFactory = (db: TDbClient) => {
role,
status,
isActive,
- inviteEmail
+ inviteEmail,
+ lastLoggedInAuthMethod
}) => ({
roleId,
orgId,
@@ -73,6 +75,7 @@ export const orgMembershipDALFactory = (db: TDbClient) => {
status,
isActive,
inviteEmail,
+ lastLoggedInAuthMethod,
user: {
id: userId,
email,
diff --git a/backend/src/services/org/org-dal.ts b/backend/src/services/org/org-dal.ts
index b96e800a78..9f085284ac 100644
--- a/backend/src/services/org/org-dal.ts
+++ b/backend/src/services/org/org-dal.ts
@@ -285,6 +285,7 @@ export const orgDALFactory = (db: TDbClient) => {
db.ref("roleId").withSchema(TableName.OrgMembership),
db.ref("status").withSchema(TableName.OrgMembership),
db.ref("isActive").withSchema(TableName.OrgMembership),
+ db.ref("lastLoggedInAuthMethod").withSchema(TableName.OrgMembership),
db.ref("email").withSchema(TableName.Users),
db.ref("isEmailVerified").withSchema(TableName.Users),
db.ref("username").withSchema(TableName.Users),
diff --git a/frontend/src/components/organization/LastLoginSection/LastLoginSection.tsx b/frontend/src/components/organization/LastLoginSection/LastLoginSection.tsx
new file mode 100644
index 0000000000..50ad653c3e
--- /dev/null
+++ b/frontend/src/components/organization/LastLoginSection/LastLoginSection.tsx
@@ -0,0 +1,23 @@
+import { faEnvelope } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+type Props = {
+ lastLoggedInAuthMethod: string;
+};
+
+export const LastLoginSection = ({ lastLoggedInAuthMethod }: Props) => (
+ <div className="">
+ <div className="mb-2 flex items-center gap-2 border-b border-mineshaft-600 pb-1">
+ <div className="font-medium">Last Login Details</div>
+ </div>
+ <div className="flex items-center gap-2 text-sm">
+ <div className="rounded bg-mineshaft-700 p-1 px-2">
+ <FontAwesomeIcon icon={faEnvelope} />
+ </div>
+ <div className="flex flex-col">
+ <div className="text-sm font-medium">Authentication Method</div>
+ <div className="text-sm">{lastLoggedInAuthMethod}</div>
+ </div>
+ </div>
+ </div>
+);
diff --git a/frontend/src/components/organization/LastLoginSection/index.tsx b/frontend/src/components/organization/LastLoginSection/index.tsx
new file mode 100644
index 0000000000..607358130d
--- /dev/null
+++ b/frontend/src/components/organization/LastLoginSection/index.tsx
@@ -0,0 +1 @@
+export { LastLoginSection } from "./LastLoginSection";
diff --git a/frontend/src/components/v2/Badge/Badge.tsx b/frontend/src/components/v2/Badge/Badge.tsx
index 4355b0251f..0e6addd775 100644
--- a/frontend/src/components/v2/Badge/Badge.tsx
+++ b/frontend/src/components/v2/Badge/Badge.tsx
@@ -1,3 +1,4 @@
+import { forwardRef } from "react";
import { cva, VariantProps } from "cva";
import { twMerge } from "tailwind-merge";
@@ -24,13 +25,16 @@ const badgeVariants = cva(
export type BadgeProps = VariantProps<typeof badgeVariants> & IProps;
-export const Badge = ({ children, className, variant, ...props }: BadgeProps) => {
- return (
- <div
- className={twMerge(badgeVariants({ variant: variant || "primary" }), className)}
- {...props}
- >
- {children}
- </div>
- );
-};
+export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
+ ({ children, className, variant, ...props }, ref) => {
+ return (
+ <div
+ className={twMerge(badgeVariants({ variant: variant || "primary" }), className)}
+ {...props}
+ ref={ref}
+ >
+ {children}
+ </div>
+ );
+ }
+);
diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.ts
index c0e49e987a..13472347be 100644
--- a/frontend/src/hooks/api/identities/types.ts
+++ b/frontend/src/hooks/api/identities/types.ts
@@ -41,6 +41,7 @@ export type IdentityMembershipOrg = {
id: string;
identity: Identity;
organization: string;
+ lastLoggedInAuthMethod?: IdentityAuthMethod;
metadata: { key: string; value: string; id: string }[];
role: "admin" | "member" | "viewer" | "no-access" | "custom";
customRole?: TOrgRole;
diff --git a/frontend/src/hooks/api/users/types.ts b/frontend/src/hooks/api/users/types.ts
index 48da6f7d1c..ff25846cb1 100644
--- a/frontend/src/hooks/api/users/types.ts
+++ b/frontend/src/hooks/api/users/types.ts
@@ -68,6 +68,7 @@ export type OrgUser = {
deniedPermissions: any[];
roleId: string;
isActive: boolean;
+ lastLoggedInAuthMethod?: AuthMethod;
};
export type TProjectMembership = {
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
index 407ee3a554..0a5124013c 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -7,6 +7,7 @@ import {
faEdit,
faEllipsisV,
faFilter,
+ faInfoCircle,
faMagnifyingGlass,
faServer,
faTrash
@@ -16,6 +17,7 @@ import { useNavigate } from "@tanstack/react-router";
import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
+import { LastLoginSection } from "@app/components/organization/LastLoginSection";
import { OrgPermissionCan } from "@app/components/permissions";
import {
DropdownMenu,
@@ -40,6 +42,7 @@ import {
Td,
Th,
THead,
+ Tooltip,
Tr
} from "@app/components/v2";
import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context";
@@ -284,112 +287,129 @@ export const IdentityTable = ({ handlePopUpOpen }: Props) => {
<TBody>
{isPending && <TableSkeleton columns={3} innerKey="org-identities" />}
{!isPending &&
- data?.identities?.map(({ identity: { id, name }, role, customRole }) => {
- return (
- <Tr
- className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
- key={`identity-${id}`}
- onClick={() =>
- navigate({
- to: "/organization/identities/$identityId",
- params: {
- identityId: id
- }
- })
- }
- >
- <Td>{name}</Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionIdentityActions.Edit}
- a={OrgPermissionSubjects.Identity}
- >
- {(isAllowed) => {
- return (
- <Select
- value={role === "custom" ? (customRole?.slug as string) : role}
- isDisabled={!isAllowed}
- className="h-8 w-48 bg-mineshaft-700"
- position="popper"
- dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
- onValueChange={(selectedRole) =>
- handleChangeRole({
- identityId: id,
- role: selectedRole
- })
- }
- >
- {(roles || []).map(({ slug, name: roleName }) => (
- <SelectItem value={slug} key={`owner-option-${slug}`}>
- {roleName}
- </SelectItem>
- ))}
- </Select>
- );
- }}
- </OrgPermissionCan>
- </Td>
- <Td>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- ariaLabel="Options"
- className="w-6"
- colorSchema="secondary"
- variant="plain"
- >
- <FontAwesomeIcon icon={faEllipsisV} />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent sideOffset={2} align="end">
- <OrgPermissionCan
- I={OrgPermissionIdentityActions.Edit}
- a={OrgPermissionSubjects.Identity}
+ data?.identities?.map(
+ ({ identity: { id, name }, role, customRole, lastLoggedInAuthMethod }) => {
+ return (
+ <Tr
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`identity-${id}`}
+ onClick={() =>
+ navigate({
+ to: "/organization/identities/$identityId",
+ params: {
+ identityId: id
+ }
+ })
+ }
+ >
+ <Td className="group">
+ {name}
+ {lastLoggedInAuthMethod && (
+ <Tooltip
+ className="min-w-52 max-w-96"
+ content={
+ <LastLoginSection lastLoggedInAuthMethod={lastLoggedInAuthMethod} />
+ }
>
- {(isAllowed) => (
- <DropdownMenuItem
- icon={<FontAwesomeIcon icon={faEdit} />}
- onClick={(e) => {
- e.stopPropagation();
- navigate({
- to: "/organization/identities/$identityId",
- params: {
- identityId: id
- }
- });
- }}
+ <FontAwesomeIcon
+ icon={faInfoCircle}
+ className="ml-2 text-mineshaft-400 opacity-0 transition-all group-hover:opacity-100"
+ />
+ </Tooltip>
+ )}
+ </Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionIdentityActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => {
+ return (
+ <Select
+ value={role === "custom" ? (customRole?.slug as string) : role}
isDisabled={!isAllowed}
- >
- Edit Identity
- </DropdownMenuItem>
- )}
- </OrgPermissionCan>
- <OrgPermissionCan
- I={OrgPermissionIdentityActions.Delete}
- a={OrgPermissionSubjects.Identity}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handlePopUpOpen("deleteIdentity", {
+ className="h-8 w-48 bg-mineshaft-700"
+ position="popper"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={(selectedRole) =>
+ handleChangeRole({
identityId: id,
- name
- });
- }}
- isDisabled={!isAllowed}
- icon={<FontAwesomeIcon icon={faTrash} />}
+ role: selectedRole
+ })
+ }
>
- Delete Identity
- </DropdownMenuItem>
- )}
- </OrgPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
- </Td>
- </Tr>
- );
- })}
+ {(roles || []).map(({ slug, name: roleName }) => (
+ <SelectItem value={slug} key={`owner-option-${slug}`}>
+ {roleName}
+ </SelectItem>
+ ))}
+ </Select>
+ );
+ }}
+ </OrgPermissionCan>
+ </Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ ariaLabel="Options"
+ className="w-6"
+ colorSchema="secondary"
+ variant="plain"
+ >
+ <FontAwesomeIcon icon={faEllipsisV} />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent sideOffset={2} align="end">
+ <OrgPermissionCan
+ I={OrgPermissionIdentityActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ icon={<FontAwesomeIcon icon={faEdit} />}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate({
+ to: "/organization/identities/$identityId",
+ params: {
+ identityId: id
+ }
+ });
+ }}
+ isDisabled={!isAllowed}
+ >
+ Edit Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionIdentityActions.Delete}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteIdentity", {
+ identityId: id,
+ name
+ });
+ }}
+ isDisabled={!isAllowed}
+ icon={<FontAwesomeIcon icon={faTrash} />}
+ >
+ Delete Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ );
+ }
+ )}
</TBody>
</Table>
{!isPending && data && totalCount > 0 && (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
index 679e9f6647..4788c51cd6 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
@@ -7,6 +7,7 @@ import {
faEdit,
faEllipsisV,
faFilter,
+ faInfoCircle,
faMagnifyingGlass,
faSearch,
faUsers,
@@ -19,6 +20,7 @@ import { useNavigate } from "@tanstack/react-router";
import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
+import { LastLoginSection } from "@app/components/organization/LastLoginSection";
import { OrgPermissionCan } from "@app/components/permissions";
import {
Badge,
@@ -471,7 +473,16 @@ export const OrgMembersTable = ({
{isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
{!isLoading &&
filteredMembersPage.map(
- ({ user: u, inviteEmail, role, roleId, id: orgMembershipId, status, isActive }) => {
+ ({
+ user: u,
+ inviteEmail,
+ role,
+ roleId,
+ id: orgMembershipId,
+ status,
+ isActive,
+ lastLoggedInAuthMethod
+ }) => {
const name =
u && u.firstName ? `${u.firstName} ${u.lastName ?? ""}`.trim() : null;
const email = u?.email || inviteEmail;
@@ -504,7 +515,9 @@ export const OrgMembersTable = ({
}}
/>
</Td>
- <Td className={twMerge("max-w-0", isActive ? "" : "text-mineshaft-400")}>
+ <Td
+ className={twMerge("group max-w-0", isActive ? "" : "text-mineshaft-400")}
+ >
<div className="flex items-center">
<p className="truncate">
{name ?? <span className="text-mineshaft-400">Not Set</span>}
@@ -517,6 +530,19 @@ export const OrgMembersTable = ({
</Tooltip>
</Badge>
)}
+ {lastLoggedInAuthMethod && (
+ <Tooltip
+ className="min-w-52 max-w-96"
+ content={
+ <LastLoginSection lastLoggedInAuthMethod={lastLoggedInAuthMethod} />
+ }
+ >
+ <FontAwesomeIcon
+ icon={faInfoCircle}
+ className="ml-2 text-mineshaft-400 opacity-0 transition-all group-hover:opacity-100"
+ />
+ </Tooltip>
+ )}
</div>
</Td>
<Td className={twMerge("max-w-0", isActive ? "" : "text-mineshaft-400")}>
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx
index 328c5505dc..339dac41d8 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx
@@ -138,6 +138,10 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =
<p className="text-sm font-semibold text-mineshaft-300">Name</p>
<p className="text-sm text-mineshaft-300">{data.identity.name}</p>
</div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Last Login Auth Method</p>
+ <p className="text-sm text-mineshaft-300">{data.lastLoggedInAuthMethod || "-"}</p>
+ </div>
<div className="mb-4">
<p className="text-sm font-semibold text-mineshaft-300">Delete Protection</p>
<p className="text-sm text-mineshaft-300">
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
index a54750aa66..50f3804d08 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
@@ -159,6 +159,14 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
</p>
</div>
</div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Last Login Auth Method</p>
+ <div className="group flex align-top">
+ <p className="break-all text-sm text-mineshaft-300">
+ {membership.lastLoggedInAuthMethod || "-"}
+ </p>
+ </div>
+ </div>
<div className="mb-4">
<p className="text-sm font-semibold text-mineshaft-300">Organization Role</p>
<p className="text-sm text-mineshaft-300">{roleName ?? "-"}</p>