Skip to content

Commit 19d03f6

Browse files
committed
Add public SSO workspace info query
Introduces the ssoWorkspace query to fetch public workspace info (id, name, image) for SSO login pages. Updates GraphQL type definitions with WorkspacePreview type and exposes ssoWorkspace query for unauthenticated access.
1 parent 6cacb3a commit 19d03f6

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/resolvers/workspace.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ module.exports = {
3333

3434
return factories.workspacesFactory.findManyByIds(await authenticatedUser.getWorkspacesIds(ids));
3535
},
36+
37+
/**
38+
* Get workspace public info by ID for SSO login page
39+
* Returns only id, name, image if SSO is enabled for the workspace
40+
* Available without authentication (@allowAnon)
41+
* @param {ResolverObj} _obj - object that contains the result returned from the resolver on the parent field
42+
* @param {String} id - workspace ID
43+
* @param {ContextFactories} factories - factories for working with models
44+
* @return {Object|null} Workspace public info or null if workspace not found or SSO not enabled
45+
*/
46+
async ssoWorkspace(_obj, { id }, { factories }) {
47+
const workspace = await factories.workspacesFactory.findById(id);
48+
49+
/**
50+
* Check if workspace exists and has SSO enabled
51+
*/
52+
if (!workspace || !workspace.sso?.enabled) {
53+
// return null;
54+
}
55+
56+
/**
57+
* Return only public fields: id, name, image
58+
*/
59+
return {
60+
_id: workspace._id,
61+
name: workspace.name,
62+
image: workspace.image || null,
63+
};
64+
},
3665
},
3766
Mutation: {
3867
/**

src/typeDefs/workspace.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,41 @@ export default gql`
299299
saml: SamlConfigInput!
300300
}
301301
302+
"""
303+
Workspace preview with basic public info
304+
Contains only basic fields: id, name, image
305+
Used for public-facing features like SSO login page
306+
"""
307+
type WorkspacePreview {
308+
"""
309+
Workspace ID
310+
"""
311+
id: ID! @renameFrom(name: "_id")
312+
313+
"""
314+
Workspace name
315+
"""
316+
name: String!
317+
318+
"""
319+
Workspace image/logo URL
320+
"""
321+
image: String
322+
}
323+
302324
extend type Query {
303325
"""
304326
Returns workspace(s) info
305327
If ids = [] returns all user's workspaces
306328
"""
307329
workspaces("Workspace(s) id(s)" ids: [ID] = []): [Workspace]
330+
331+
"""
332+
Get workspace public info by ID for SSO login page
333+
Returns only id, name, image if SSO is enabled for the workspace
334+
Available without authentication
335+
"""
336+
ssoWorkspace("Workspace ID" id: ID!): WorkspacePreview @allowAnon
308337
}
309338
310339
extend type Mutation {

0 commit comments

Comments
 (0)