Skip to content

Commit c4454bc

Browse files
authored
Merge pull request #62 from codex-team/sso
chore(sso): sso types added
2 parents 2a3dfda + f1db0c0 commit c4454bc

File tree

11 files changed

+227
-1
lines changed

11 files changed

+227
-1
lines changed

build/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export * from "./src/dbScheme/user";
2323
export * from "./src/dbScheme/userNotifications";
2424
export * from "./src/dbScheme/workspace";
2525
export * from "./src/dbScheme/bankCard";
26+
export * from "./src/dbScheme/sso";
2627
export * from "./src/dbScheme/projectEventGroupingPattern";
2728
export * from "./src/notifications/createProjectNotifications";
2829
export * from "./src/notifications/receiveTypes";

build/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ __exportStar(require("./src/dbScheme/user"), exports);
3939
__exportStar(require("./src/dbScheme/userNotifications"), exports);
4040
__exportStar(require("./src/dbScheme/workspace"), exports);
4141
__exportStar(require("./src/dbScheme/bankCard"), exports);
42+
__exportStar(require("./src/dbScheme/sso"), exports);
4243
__exportStar(require("./src/dbScheme/projectEventGroupingPattern"), exports);
4344
__exportStar(require("./src/notifications/createProjectNotifications"), exports);
4445
__exportStar(require("./src/notifications/receiveTypes"), exports);

build/src/dbScheme/sso.d.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* SSO configuration types for database schema
3+
*/
4+
/**
5+
* SAML attribute mapping configuration
6+
*/
7+
export interface SamlAttributeMapping {
8+
/**
9+
* Attribute name for email in SAML Assertion
10+
* @example "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
11+
* to get email from XML like this:
12+
* <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
13+
* <AttributeValue>[email protected]</AttributeValue>
14+
* </Attribute>
15+
*/
16+
email: string;
17+
/**
18+
* Attribute name for user name in SAML Assertion
19+
*/
20+
name?: string;
21+
}
22+
/**
23+
* SAML SSO configuration
24+
*/
25+
export interface SamlConfig {
26+
/**
27+
* IdP Entity ID.
28+
* Used to validate "this response is intended for Hawk"
29+
* @example "urn:hawk:tracker:saml"
30+
*/
31+
idpEntityId: string;
32+
/**
33+
* SSO URL for redirecting user to IdP
34+
* Used to redirect user to IdP for authentication
35+
* @example "https://idp.example.com/sso"
36+
*/
37+
ssoUrl: string;
38+
/**
39+
* X.509 certificate for signature verification
40+
* @example "-----BEGIN CERTIFICATE-----\nMIIDYjCCAkqgAwIBAgI...END CERTIFICATE-----"
41+
*/
42+
x509Cert: string;
43+
/**
44+
* Desired NameID format
45+
* @example "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
46+
*/
47+
nameIdFormat?: string;
48+
/**
49+
* Attribute mapping configuration
50+
* Used to extract user attributes from SAML Response
51+
*/
52+
attributeMapping: SamlAttributeMapping;
53+
}
54+
/**
55+
* SSO configuration for workspace
56+
*/
57+
export interface WorkspaceSsoConfig {
58+
/**
59+
* Is SSO enabled
60+
*/
61+
enabled: boolean;
62+
/**
63+
* Is SSO enforced (only SSO login allowed)
64+
* If true, login via email/password is not allowed
65+
*/
66+
enforced: boolean;
67+
/**
68+
* SSO provider type
69+
* Currently only SAML is supported. In future we can add other providers (OAuth 2, etc.)
70+
*/
71+
type: 'saml';
72+
/**
73+
* SAML-specific configuration.
74+
* Got from IdP metadata.
75+
*/
76+
saml: SamlConfig;
77+
}

build/src/dbScheme/sso.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
/**
3+
* SSO configuration types for database schema
4+
*/
5+
Object.defineProperty(exports, "__esModule", { value: true });

build/src/dbScheme/user.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,24 @@ export interface UserDBScheme {
6767
*/
6868
term?: string;
6969
};
70+
/**
71+
* External identities for SSO (keyed by workspaceId)
72+
*/
73+
identities?: {
74+
[workspaceId: string]: {
75+
/**
76+
* SAML-mode params
77+
*/
78+
saml: {
79+
/**
80+
* NameID value from IdP (stable identifier)
81+
*/
82+
id: string;
83+
/**
84+
* Email at the time of linking (for audit)
85+
*/
86+
email: string;
87+
};
88+
};
89+
};
7090
}

build/src/dbScheme/workspace.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ObjectId } from 'bson';
2+
import type { WorkspaceSsoConfig } from './sso.ts';
23
/**
34
* Workspace representation in DataBase
45
*/
@@ -68,4 +69,8 @@ export interface WorkspaceDBScheme {
6869
lastNotificationDate?: {
6970
[key: string]: Date;
7071
};
72+
/**
73+
* SSO configuration (optional, only for workspaces with SSO enabled)
74+
*/
75+
sso?: WorkspaceSsoConfig;
7176
}

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export * from "./src/dbScheme/user";
2828
export * from "./src/dbScheme/userNotifications";
2929
export * from "./src/dbScheme/workspace";
3030
export * from "./src/dbScheme/bankCard";
31+
export * from "./src/dbScheme/sso";
3132
export * from "./src/dbScheme/projectEventGroupingPattern";
3233

3334
export * from "./src/notifications/createProjectNotifications";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hawk.so/types",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "TypeScript definitions for Hawk",
55
"types": "build/index.d.ts",
66
"main": "build/index.js",

src/dbScheme/sso.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* SSO configuration types for database schema
3+
*/
4+
5+
/**
6+
* SAML attribute mapping configuration
7+
*/
8+
export interface SamlAttributeMapping {
9+
/**
10+
* Attribute name for email in SAML Assertion
11+
* @example "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
12+
* to get email from XML like this:
13+
* <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
14+
* <AttributeValue>[email protected]</AttributeValue>
15+
* </Attribute>
16+
*/
17+
email: string;
18+
19+
/**
20+
* Attribute name for user name in SAML Assertion
21+
*/
22+
name?: string;
23+
}
24+
25+
/**
26+
* SAML SSO configuration
27+
*/
28+
export interface SamlConfig {
29+
/**
30+
* IdP Entity ID.
31+
* Used to validate "this response is intended for Hawk"
32+
* @example "urn:hawk:tracker:saml"
33+
*/
34+
idpEntityId: string;
35+
36+
/**
37+
* SSO URL for redirecting user to IdP
38+
* Used to redirect user to IdP for authentication
39+
* @example "https://idp.example.com/sso"
40+
*/
41+
ssoUrl: string;
42+
43+
/**
44+
* X.509 certificate for signature verification
45+
* @example "-----BEGIN CERTIFICATE-----\nMIIDYjCCAkqgAwIBAgI...END CERTIFICATE-----"
46+
*/
47+
x509Cert: string;
48+
49+
/**
50+
* Desired NameID format
51+
* @example "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
52+
*/
53+
nameIdFormat?: string;
54+
55+
/**
56+
* Attribute mapping configuration
57+
* Used to extract user attributes from SAML Response
58+
*/
59+
attributeMapping: SamlAttributeMapping;
60+
}
61+
62+
/**
63+
* SSO configuration for workspace
64+
*/
65+
export interface WorkspaceSsoConfig {
66+
/**
67+
* Is SSO enabled
68+
*/
69+
enabled: boolean;
70+
71+
/**
72+
* Is SSO enforced (only SSO login allowed)
73+
* If true, login via email/password is not allowed
74+
*/
75+
enforced: boolean;
76+
77+
/**
78+
* SSO provider type
79+
* Currently only SAML is supported. In future we can add other providers (OAuth 2, etc.)
80+
*/
81+
type: 'saml';
82+
83+
/**
84+
* SAML-specific configuration.
85+
* Got from IdP metadata.
86+
*/
87+
saml: SamlConfig;
88+
}

src/dbScheme/user.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,26 @@ export interface UserDBScheme {
8181
*/
8282
term?: string;
8383
};
84+
85+
/**
86+
* External identities for SSO (keyed by workspaceId)
87+
*/
88+
identities?: {
89+
[workspaceId: string]: {
90+
/**
91+
* SAML-mode params
92+
*/
93+
saml: {
94+
/**
95+
* NameID value from IdP (stable identifier)
96+
*/
97+
id: string;
98+
99+
/**
100+
* Email at the time of linking (for audit)
101+
*/
102+
email: string;
103+
};
104+
};
105+
};
84106
}

0 commit comments

Comments
 (0)