Merge pull request #1283 from Infisical/identity-apis

Update various identities items
This commit is contained in:
BlackMagiq
2024-01-06 17:11:01 +01:00
committed by GitHub
6 changed files with 38 additions and 20 deletions
+2 -1
View File
@@ -4962,7 +4962,8 @@
}, },
"security": [ "security": [
{ {
"apiKeyAuth": [] "apiKeyAuth": [],
"bearerAuth": []
} }
] ]
} }
@@ -1,9 +1,13 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import { Types } from "mongoose"; import { Types } from "mongoose";
import { import {
IdentityMembershipOrg, IWorkspace,
Membership, Identity,
IdentityMembership,
IdentityMembershipOrg,
Membership,
MembershipOrg, MembershipOrg,
User,
Workspace Workspace
} from "../../models"; } from "../../models";
import { Role } from "../../ee/models"; import { Role } from "../../ee/models";
@@ -298,7 +302,8 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) =>
#swagger.description = 'Return projects in organization that user is part of' #swagger.description = 'Return projects in organization that user is part of'
#swagger.security = [{ #swagger.security = [{
"apiKeyAuth": [] "apiKeyAuth": [],
"bearerAuth": []
}] }]
#swagger.parameters['organizationId'] = { #swagger.parameters['organizationId'] = {
@@ -326,6 +331,7 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) =>
} }
} }
*/ */
const { const {
params: { organizationId } params: { organizationId }
} = await validateRequest(reqValidator.GetOrgWorkspacesv2, req); } = await validateRequest(reqValidator.GetOrgWorkspacesv2, req);
@@ -351,13 +357,27 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) =>
).map((w) => w._id.toString()) ).map((w) => w._id.toString())
); );
const workspaces = ( let workspaces: IWorkspace[] = [];
await Membership.find({
user: req.user._id if (req.authData.authPayload instanceof Identity) {
}).populate("workspace") workspaces = (
) await IdentityMembership.find({
.filter((m) => workspacesSet.has(m.workspace._id.toString())) identity: req.authData.authPayload._id
.map((m) => m.workspace); }).populate<{ workspace: IWorkspace }>("workspace")
)
.filter((m) => workspacesSet.has(m.workspace._id.toString()))
.map((m) => m.workspace);
}
if (req.authData.authPayload instanceof User) {
workspaces = (
await Membership.find({
user: req.authData.authPayload._id
}).populate<{ workspace: IWorkspace }>("workspace")
)
.filter((m) => workspacesSet.has(m.workspace._id.toString()))
.map((m) => m.workspace);
}
return res.status(200).send({ return res.status(200).send({
workspaces workspaces
@@ -1,10 +1,4 @@
--- ---
title: "Get Projects" title: "Get Projects"
openapi: "GET /api/v2/organizations/{organizationId}/workspaces" openapi: "GET /api/v2/organizations/{organizationId}/workspaces"
--- ---
<Warning>
This endpoint will be deprecated in the near future in Q1/Q2 2024.
We recommend switching to using [identities](/documentation/platform/identities/overview).
</Warning>
+1
View File
@@ -3133,6 +3133,7 @@ paths:
description: Projects of organization description: Projects of organization
security: security:
- apiKeyAuth: [] - apiKeyAuth: []
bearerAuth: []
/api/v2/organizations/: /api/v2/organizations/:
post: post:
description: '' description: ''
@@ -72,9 +72,9 @@ export const IdentitySection = withPermission(
</p> </p>
<div className="flex justify-end w-full pr-4"> <div className="flex justify-end w-full pr-4">
<Link href="https://infisical.com/docs/documentation/platform/identities/overview"> <Link href="https://infisical.com/docs/documentation/platform/identities/overview">
<span className="rounded-md px-4 py-2 w-max text-mineshaft-200 hover:text-white bg-mineshaft-600 border border-mineshaft-500 hover:bg-primary/10 hover:border-primary/40 duration-200 cursor-pointer"> <a target="_blank" rel="noopener noreferrer" className="rounded-md px-4 py-2 w-max text-mineshaft-200 hover:text-white bg-mineshaft-600 border border-mineshaft-500 hover:bg-primary/10 hover:border-primary/40 duration-200 cursor-pointer">
Documentation <FontAwesomeIcon icon={faArrowUpRightFromSquare} className="text-xs mb-[0.06rem] ml-1"/> Documentation <FontAwesomeIcon icon={faArrowUpRightFromSquare} className="text-xs mb-[0.06rem] ml-1"/>
</span> </a>
</Link> </Link>
</div> </div>
<OrgPermissionCan <OrgPermissionCan
@@ -98,6 +98,7 @@ export const IdentityTable = ({
<THead> <THead>
<Tr> <Tr>
<Th>Name</Th> <Th>Name</Th>
<Th>ID</Th>
<Th>Role</Th> <Th>Role</Th>
<Th>Auth Method</Th> <Th>Auth Method</Th>
<Th className="w-5" /> <Th className="w-5" />
@@ -120,6 +121,7 @@ export const IdentityTable = ({
return ( return (
<Tr className="h-10" key={`identity-${_id}`}> <Tr className="h-10" key={`identity-${_id}`}>
<Td>{name}</Td> <Td>{name}</Td>
<Td>{_id}</Td>
<Td> <Td>
<OrgPermissionCan <OrgPermissionCan
I={OrgPermissionActions.Edit} I={OrgPermissionActions.Edit}