@sso-id/cli 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { SCIM_CORE_GROUP_SCHEMA, SCIM_CORE_USER_SCHEMA } from '@sso-id/node';
|
|
3
|
-
import { getManagementClient, scimStore } from '@/lib/sso';
|
|
3
|
+
import { getManagementClient, requireAppAuth, scimStore } from '@/lib/sso';
|
|
4
|
+
|
|
5
|
+
export async function GET(req: Request) {
|
|
6
|
+
const authErr = requireAppAuth(req);
|
|
7
|
+
if (authErr) return authErr;
|
|
4
8
|
|
|
5
|
-
export async function GET() {
|
|
6
9
|
return NextResponse.json({
|
|
7
10
|
users: Array.from(scimStore.users.values()),
|
|
8
11
|
groups: Array.from(scimStore.groups.values()),
|
|
@@ -11,6 +14,9 @@ export async function GET() {
|
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export async function POST(req: Request) {
|
|
17
|
+
const authErr = requireAppAuth(req);
|
|
18
|
+
if (authErr) return authErr;
|
|
19
|
+
|
|
14
20
|
const body = (await req.json()) as {
|
|
15
21
|
type: 'User' | 'Group';
|
|
16
22
|
userName?: string;
|
|
@@ -45,6 +51,7 @@ export async function POST(req: Request) {
|
|
|
45
51
|
displayName: body.displayName || 'New Group',
|
|
46
52
|
members: [],
|
|
47
53
|
});
|
|
54
|
+
if (created.id) scimStore.groups.set(created.id, created);
|
|
48
55
|
scimStore.record({
|
|
49
56
|
direction: 'outbound',
|
|
50
57
|
resourceType: 'Group',
|
|
@@ -58,4 +65,3 @@ export async function POST(req: Request) {
|
|
|
58
65
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
|
-
|
|
@@ -1,37 +1,63 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { useSsoId } from '@sso-id/react';
|
|
5
|
-
import { SignInButton, UserMenu } from '@sso-id/ui';
|
|
6
5
|
|
|
7
|
-
type
|
|
6
|
+
type Section = 'overview' | 'organizations' | 'organization-units' | 'users' | 'groups' | 'scim';
|
|
7
|
+
|
|
8
|
+
interface ScimState {
|
|
9
|
+
users: Array<Record<string, any>>;
|
|
10
|
+
groups: Array<Record<string, any>>;
|
|
11
|
+
events: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
direction: string;
|
|
15
|
+
resourceType: string;
|
|
16
|
+
operation: string;
|
|
17
|
+
targetId: string;
|
|
18
|
+
summary: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
8
21
|
|
|
9
22
|
export default function HomePage() {
|
|
10
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
isAuthenticated: spaAuthed,
|
|
25
|
+
user: spaUser,
|
|
26
|
+
isLoading: spaLoading,
|
|
27
|
+
loginWithRedirect,
|
|
28
|
+
logout: spaLogout,
|
|
29
|
+
getAccessTokenSilently,
|
|
30
|
+
} = useSsoId();
|
|
31
|
+
|
|
11
32
|
const [serverUser, setServerUser] = useState<Record<string, unknown> | null>(null);
|
|
12
33
|
const [serverChecked, setServerChecked] = useState(false);
|
|
13
|
-
const [
|
|
14
|
-
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
34
|
+
const [section, setSection] = useState<Section>('overview');
|
|
35
|
+
|
|
36
|
+
const [organizations, setOrganizations] = useState<Array<Record<string, any>>>([]);
|
|
37
|
+
const [orgUnits, setOrgUnits] = useState<Array<Record<string, any>>>([]);
|
|
38
|
+
const [users, setUsers] = useState<Array<Record<string, any>>>([]);
|
|
39
|
+
const [groups, setGroups] = useState<Array<Record<string, any>>>([]);
|
|
40
|
+
const [scimState, setScimState] = useState<ScimState>({ users: [], groups: [], events: [] });
|
|
41
|
+
|
|
42
|
+
const [loadingData, setLoadingData] = useState(false);
|
|
43
|
+
const [showRawJson, setShowRawJson] = useState(false);
|
|
44
|
+
const [toast, setToast] = useState<{ type: 'ok' | 'err'; text: string } | null>(null);
|
|
45
|
+
|
|
46
|
+
// Form states
|
|
24
47
|
const [name, setName] = useState('');
|
|
25
48
|
const [email, setEmail] = useState('');
|
|
26
|
-
const [
|
|
27
|
-
const [
|
|
49
|
+
const [selectedOrgId, setSelectedOrgId] = useState('');
|
|
50
|
+
const [scimPushType, setScimPushType] = useState<'User' | 'Group'>('User');
|
|
51
|
+
const [submitting, setSubmitting] = useState(false);
|
|
28
52
|
|
|
29
53
|
const isAuthenticated = spaAuthed || Boolean(serverUser);
|
|
30
54
|
const activeUser = (spaUser as Record<string, unknown> | null) || serverUser;
|
|
31
|
-
const
|
|
55
|
+
const isCheckingAuth = spaLoading || !serverChecked;
|
|
56
|
+
|
|
57
|
+
const domain = process.env.NEXT_PUBLIC_SSO_ID_DOMAIN || 'account.oerps.com';
|
|
32
58
|
|
|
33
59
|
useEffect(() => {
|
|
34
|
-
fetch('/api/auth/me')
|
|
60
|
+
fetch('/api/auth/me', { credentials: 'include' })
|
|
35
61
|
.then((r) => r.json())
|
|
36
62
|
.then((res: { authenticated?: boolean; user?: Record<string, unknown> | null }) => {
|
|
37
63
|
if (res?.authenticated && res.user) {
|
|
@@ -42,168 +68,782 @@ export default function HomePage() {
|
|
|
42
68
|
.finally(() => setServerChecked(true));
|
|
43
69
|
}, []);
|
|
44
70
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
const authFetch = useCallback(
|
|
72
|
+
async (url: string, init?: RequestInit) => {
|
|
73
|
+
const headers: Record<string, string> = {
|
|
74
|
+
...(init?.headers as Record<string, string> | undefined),
|
|
75
|
+
};
|
|
76
|
+
if (init?.body) {
|
|
77
|
+
headers['Content-Type'] = 'application/json';
|
|
78
|
+
}
|
|
79
|
+
if (spaAuthed) {
|
|
80
|
+
try {
|
|
81
|
+
const tok = await getAccessTokenSilently();
|
|
82
|
+
if (tok) headers.Authorization = `Bearer ${tok}`;
|
|
83
|
+
} catch {
|
|
84
|
+
// Use server cookie fallback
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return fetch(url, { ...init, headers, credentials: 'include' });
|
|
88
|
+
},
|
|
89
|
+
[spaAuthed, getAccessTokenSilently],
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const loadAllProtectedData = useCallback(async () => {
|
|
93
|
+
if (!isAuthenticated) return;
|
|
94
|
+
setLoadingData(true);
|
|
95
|
+
try {
|
|
96
|
+
const [orgRes, ouRes, usrRes, grpRes, scimRes] = await Promise.all([
|
|
97
|
+
authFetch('/api/management/organizations'),
|
|
98
|
+
authFetch('/api/management/organization-units'),
|
|
99
|
+
authFetch('/api/management/users'),
|
|
100
|
+
authFetch('/api/management/groups'),
|
|
101
|
+
authFetch('/api/scim/sync'),
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
if (orgRes.ok) {
|
|
105
|
+
const list = await orgRes.json();
|
|
106
|
+
const arr = Array.isArray(list) ? list : [];
|
|
107
|
+
setOrganizations(arr);
|
|
108
|
+
if (arr.length > 0 && !selectedOrgId) {
|
|
109
|
+
setSelectedOrgId(arr[0].organizationId || '');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (ouRes.ok) {
|
|
113
|
+
const list = await ouRes.json();
|
|
114
|
+
setOrgUnits(Array.isArray(list) ? list : []);
|
|
115
|
+
}
|
|
116
|
+
if (usrRes.ok) {
|
|
117
|
+
const list = await usrRes.json();
|
|
118
|
+
setUsers(Array.isArray(list) ? list : []);
|
|
119
|
+
}
|
|
120
|
+
if (grpRes.ok) {
|
|
121
|
+
const list = await grpRes.json();
|
|
122
|
+
setGroups(Array.isArray(list) ? list : []);
|
|
123
|
+
}
|
|
124
|
+
if (scimRes.ok) {
|
|
125
|
+
setScimState(await scimRes.json());
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
setToast({ type: 'err', text: String(err) });
|
|
129
|
+
} finally {
|
|
130
|
+
setLoadingData(false);
|
|
51
131
|
}
|
|
52
|
-
|
|
53
|
-
setData(await res.json());
|
|
54
|
-
}
|
|
132
|
+
}, [isAuthenticated, authFetch, selectedOrgId]);
|
|
55
133
|
|
|
56
134
|
useEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
135
|
+
if (isAuthenticated) {
|
|
136
|
+
void loadAllProtectedData();
|
|
137
|
+
}
|
|
138
|
+
}, [isAuthenticated, loadAllProtectedData]);
|
|
59
139
|
|
|
60
140
|
async function handleCreate(e: React.FormEvent) {
|
|
61
141
|
e.preventDefault();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
142
|
+
setSubmitting(true);
|
|
143
|
+
setToast(null);
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
let endpoint = `/api/management/${section}`;
|
|
147
|
+
let body: Record<string, unknown> = { name };
|
|
148
|
+
|
|
149
|
+
if (section === 'organization-units') {
|
|
150
|
+
body = { name, organizationId: selectedOrgId };
|
|
151
|
+
} else if (section === 'users') {
|
|
152
|
+
body = { emailAddress: email, email, userName: email, firstName: name, lastName: 'User' };
|
|
153
|
+
} else if (section === 'groups') {
|
|
154
|
+
body = { groupId: 'new', groupName: name, name, createdBy: 'system', lastModifiedBy: 'system' };
|
|
155
|
+
} else if (section === 'scim') {
|
|
156
|
+
endpoint = '/api/scim/sync';
|
|
157
|
+
body =
|
|
158
|
+
scimPushType === 'User'
|
|
159
|
+
? { type: 'User', userName: email, displayName: name, email }
|
|
160
|
+
: { type: 'Group', displayName: name };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const res = await authFetch(endpoint, {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
body: JSON.stringify(body),
|
|
166
|
+
});
|
|
167
|
+
const json = await res.json();
|
|
168
|
+
if (!res.ok) {
|
|
169
|
+
setToast({ type: 'err', text: json.error || `Failed (${res.status})` });
|
|
170
|
+
} else {
|
|
171
|
+
setToast({ type: 'ok', text: `Successfully created ${section === 'scim' ? `SCIM ${scimPushType}` : section.replace('-', ' ')}!` });
|
|
172
|
+
setName('');
|
|
173
|
+
setEmail('');
|
|
174
|
+
await loadAllProtectedData();
|
|
175
|
+
}
|
|
176
|
+
} catch (err) {
|
|
177
|
+
setToast({ type: 'err', text: String(err) });
|
|
178
|
+
} finally {
|
|
179
|
+
setSubmitting(false);
|
|
180
|
+
}
|
|
85
181
|
}
|
|
86
182
|
|
|
87
|
-
|
|
183
|
+
function handleSignOut() {
|
|
184
|
+
if (spaAuthed) {
|
|
185
|
+
void spaLogout();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
window.location.href = '/api/auth/logout';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const displayEmail = String(
|
|
88
192
|
activeUser?.email ||
|
|
89
193
|
activeUser?.['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] ||
|
|
90
|
-
activeUser?.name ||
|
|
91
|
-
activeUser?.['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'] ||
|
|
92
194
|
activeUser?.sub ||
|
|
93
195
|
activeUser?.user_id ||
|
|
94
|
-
'',
|
|
196
|
+
'Authenticated User',
|
|
197
|
+
);
|
|
198
|
+
const displayName = String(
|
|
199
|
+
activeUser?.name ||
|
|
200
|
+
activeUser?.['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'] ||
|
|
201
|
+
displayEmail.split('@')[0],
|
|
95
202
|
);
|
|
203
|
+
const initials = displayName
|
|
204
|
+
.split(/\s+/)
|
|
205
|
+
.map((w) => w[0])
|
|
206
|
+
.join('')
|
|
207
|
+
.slice(0, 2)
|
|
208
|
+
.toUpperCase();
|
|
96
209
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<
|
|
103
|
-
|
|
210
|
+
// 1. Loading state while checking session
|
|
211
|
+
if (isCheckingAuth) {
|
|
212
|
+
return (
|
|
213
|
+
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#0f172a', color: '#f8fafc' }}>
|
|
214
|
+
<div style={{ textAlign: 'center' }}>
|
|
215
|
+
<div style={{ width: 42, height: 42, borderRadius: 12, background: 'linear-gradient(135deg,#2563eb,#7c3aed)', margin: '0 auto 14px', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 800, fontSize: 18 }}>
|
|
216
|
+
ID
|
|
217
|
+
</div>
|
|
218
|
+
<div style={{ fontSize: 15, color: '#94a3b8' }}>Verifying SSO.ID session...</div>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// 2. Unauthenticated Landing -> Protected Login Gate
|
|
225
|
+
if (!isAuthenticated) {
|
|
226
|
+
return (
|
|
227
|
+
<div
|
|
228
|
+
style={{
|
|
229
|
+
minHeight: '100vh',
|
|
230
|
+
display: 'flex',
|
|
231
|
+
alignItems: 'center',
|
|
232
|
+
justifyContent: 'center',
|
|
233
|
+
background: 'radial-gradient(circle at top left, #1e293b 0%, #0f172a 55%, #020617 100%)',
|
|
234
|
+
padding: 24,
|
|
235
|
+
color: '#f8fafc',
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
<div
|
|
239
|
+
style={{
|
|
240
|
+
width: '100%',
|
|
241
|
+
maxWidth: 460,
|
|
242
|
+
background: 'rgba(15, 23, 42, 0.85)',
|
|
243
|
+
border: '1px solid rgba(148, 163, 184, 0.18)',
|
|
244
|
+
borderRadius: 20,
|
|
245
|
+
padding: '40px 36px',
|
|
246
|
+
boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.6)',
|
|
247
|
+
}}
|
|
248
|
+
>
|
|
249
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 24 }}>
|
|
250
|
+
<div
|
|
251
|
+
style={{
|
|
252
|
+
width: 44,
|
|
253
|
+
height: 44,
|
|
254
|
+
borderRadius: 12,
|
|
255
|
+
background: 'linear-gradient(135deg, #2563eb 0%, #4f46e5 100%)',
|
|
256
|
+
display: 'flex',
|
|
257
|
+
alignItems: 'center',
|
|
258
|
+
justifyContent: 'center',
|
|
259
|
+
fontWeight: 800,
|
|
260
|
+
fontSize: 18,
|
|
261
|
+
color: '#fff',
|
|
262
|
+
boxShadow: '0 8px 20px rgba(37, 99, 235, 0.35)',
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
SSO
|
|
266
|
+
</div>
|
|
267
|
+
<div>
|
|
268
|
+
<div style={{ fontSize: 12, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', color: '#60a5fa' }}>
|
|
269
|
+
Enterprise Identity Portal
|
|
270
|
+
</div>
|
|
271
|
+
<div style={{ fontSize: 14, color: '#94a3b8' }}>{domain}</div>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<h1 style={{ margin: '0 0 10px', fontSize: 26, fontWeight: 700, letterSpacing: '-0.02em' }}>
|
|
276
|
+
Sign in to Admin Workspace
|
|
277
|
+
</h1>
|
|
278
|
+
<p style={{ margin: '0 0 28px', fontSize: 14, color: '#94a3b8', lineHeight: 1.6 }}>
|
|
279
|
+
Authenticate with your organization’s <strong>SSO.ID</strong> account to manage Organizations, Organization Units, Users, Groups, and Real-Time SCIM 2.0 provisioning.
|
|
104
280
|
</p>
|
|
281
|
+
|
|
282
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, marginBottom: 28 }}>
|
|
283
|
+
<a
|
|
284
|
+
href="/api/auth/login"
|
|
285
|
+
style={{
|
|
286
|
+
display: 'flex',
|
|
287
|
+
alignItems: 'center',
|
|
288
|
+
justifyContent: 'center',
|
|
289
|
+
gap: 10,
|
|
290
|
+
padding: '13px 20px',
|
|
291
|
+
borderRadius: 12,
|
|
292
|
+
background: 'linear-gradient(135deg, #2563eb 0%, #4f46e5 100%)',
|
|
293
|
+
color: '#ffffff',
|
|
294
|
+
fontWeight: 600,
|
|
295
|
+
fontSize: 15,
|
|
296
|
+
textDecoration: 'none',
|
|
297
|
+
boxShadow: '0 10px 25px -5px rgba(37, 99, 235, 0.45)',
|
|
298
|
+
}}
|
|
299
|
+
>
|
|
300
|
+
<span>Continue with SSO.ID</span>
|
|
301
|
+
<span>→</span>
|
|
302
|
+
</a>
|
|
303
|
+
|
|
304
|
+
<button
|
|
305
|
+
type="button"
|
|
306
|
+
onClick={() => void loginWithRedirect()}
|
|
307
|
+
style={{
|
|
308
|
+
padding: '12px 20px',
|
|
309
|
+
borderRadius: 12,
|
|
310
|
+
border: '1px solid rgba(148, 163, 184, 0.25)',
|
|
311
|
+
background: 'rgba(30, 41, 59, 0.6)',
|
|
312
|
+
color: '#e2e8f0',
|
|
313
|
+
fontWeight: 600,
|
|
314
|
+
fontSize: 14,
|
|
315
|
+
cursor: 'pointer',
|
|
316
|
+
}}
|
|
317
|
+
>
|
|
318
|
+
Sign in with Browser PKCE
|
|
319
|
+
</button>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<div style={{ borderTop: '1px solid rgba(148, 163, 184, 0.14)', paddingTop: 20, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10, fontSize: 12, color: '#94a3b8' }}>
|
|
323
|
+
<div>✓ OAuth 2.0 + PKCE</div>
|
|
324
|
+
<div>✓ RS256 JWKS Verified</div>
|
|
325
|
+
<div>✓ Multi-Tenant Orgs & OUs</div>
|
|
326
|
+
<div>✓ Real-Time SCIM 2.0</div>
|
|
327
|
+
</div>
|
|
105
328
|
</div>
|
|
329
|
+
</div>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 3. Authenticated Modern Admin Console
|
|
334
|
+
const navItems: Array<{ id: Section; label: string; badge?: number }> = [
|
|
335
|
+
{ id: 'overview', label: 'Overview' },
|
|
336
|
+
{ id: 'organizations', label: 'Organizations', badge: organizations.length },
|
|
337
|
+
{ id: 'organization-units', label: 'Organization Units', badge: orgUnits.length },
|
|
338
|
+
{ id: 'users', label: 'Users', badge: users.length },
|
|
339
|
+
{ id: 'groups', label: 'Groups', badge: groups.length },
|
|
340
|
+
{ id: 'scim', label: 'Real-Time SCIM 2.0', badge: scimState.events.length },
|
|
341
|
+
];
|
|
342
|
+
|
|
343
|
+
const activeData =
|
|
344
|
+
section === 'organizations'
|
|
345
|
+
? organizations
|
|
346
|
+
: section === 'organization-units'
|
|
347
|
+
? orgUnits
|
|
348
|
+
: section === 'users'
|
|
349
|
+
? users
|
|
350
|
+
: section === 'groups'
|
|
351
|
+
? groups
|
|
352
|
+
: scimState;
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<div style={{ display: 'flex', minHeight: '100vh', background: '#f1f5f9', color: '#0f172a' }}>
|
|
356
|
+
{/* Left Sidebar */}
|
|
357
|
+
<aside
|
|
358
|
+
style={{
|
|
359
|
+
width: 270,
|
|
360
|
+
background: '#0f172a',
|
|
361
|
+
color: '#f8fafc',
|
|
362
|
+
display: 'flex',
|
|
363
|
+
flexDirection: 'column',
|
|
364
|
+
justifyContent: 'space-between',
|
|
365
|
+
padding: '24px 16px',
|
|
366
|
+
flexShrink: 0,
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
106
369
|
<div>
|
|
107
|
-
{
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
370
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '0 8px 20px', borderBottom: '1px solid rgba(148,163,184,0.15)' }}>
|
|
371
|
+
<div
|
|
372
|
+
style={{
|
|
373
|
+
width: 38,
|
|
374
|
+
height: 38,
|
|
375
|
+
borderRadius: 10,
|
|
376
|
+
background: 'linear-gradient(135deg,#2563eb,#4f46e5)',
|
|
377
|
+
display: 'flex',
|
|
378
|
+
alignItems: 'center',
|
|
379
|
+
justifyContent: 'center',
|
|
380
|
+
fontWeight: 800,
|
|
381
|
+
fontSize: 14,
|
|
382
|
+
}}
|
|
383
|
+
>
|
|
384
|
+
SSO
|
|
385
|
+
</div>
|
|
386
|
+
<div style={{ overflow: 'hidden' }}>
|
|
387
|
+
<div style={{ fontWeight: 700, fontSize: 15, whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }}>
|
|
388
|
+
SSO.ID Console
|
|
389
|
+
</div>
|
|
390
|
+
<div style={{ fontSize: 12, color: '#94a3b8', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }}>
|
|
391
|
+
{domain}
|
|
121
392
|
</div>
|
|
122
|
-
)
|
|
123
|
-
) : (
|
|
124
|
-
<div style={{ display: 'flex', gap: 10 }}>
|
|
125
|
-
<SignInButton />
|
|
126
|
-
<a href="/api/auth/login" style={{ padding: '8px 14px', borderRadius: 8, background: '#0f172a', color: '#fff', textDecoration: 'none', fontSize: 14 }}>
|
|
127
|
-
Server Login
|
|
128
|
-
</a>
|
|
129
393
|
</div>
|
|
130
|
-
|
|
131
|
-
</div>
|
|
132
|
-
</header>
|
|
394
|
+
</div>
|
|
133
395
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
396
|
+
<div style={{ marginTop: 20, display: 'flex', flexDirection: 'column', gap: 4 }}>
|
|
397
|
+
<div style={{ fontSize: 11, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.08em', color: '#64748b', padding: '0 10px 6px' }}>
|
|
398
|
+
Workspace Modules
|
|
399
|
+
</div>
|
|
400
|
+
{navItems.map((item) => {
|
|
401
|
+
const active = section === item.id;
|
|
402
|
+
return (
|
|
403
|
+
<button
|
|
404
|
+
key={item.id}
|
|
405
|
+
type="button"
|
|
406
|
+
onClick={() => {
|
|
407
|
+
setSection(item.id);
|
|
408
|
+
setToast(null);
|
|
409
|
+
}}
|
|
410
|
+
style={{
|
|
411
|
+
display: 'flex',
|
|
412
|
+
alignItems: 'center',
|
|
413
|
+
justifyContent: 'space-between',
|
|
414
|
+
width: '100%',
|
|
415
|
+
padding: '10px 12px',
|
|
416
|
+
borderRadius: 10,
|
|
417
|
+
border: 'none',
|
|
418
|
+
background: active ? '#2563eb' : 'transparent',
|
|
419
|
+
color: active ? '#ffffff' : '#cbd5e1',
|
|
420
|
+
fontWeight: active ? 600 : 500,
|
|
421
|
+
fontSize: 14,
|
|
422
|
+
cursor: 'pointer',
|
|
423
|
+
textAlign: 'left',
|
|
424
|
+
}}
|
|
425
|
+
>
|
|
426
|
+
<span>{item.label}</span>
|
|
427
|
+
{item.badge !== undefined && (
|
|
428
|
+
<span
|
|
429
|
+
style={{
|
|
430
|
+
fontSize: 11,
|
|
431
|
+
fontWeight: 700,
|
|
432
|
+
padding: '2px 8px',
|
|
433
|
+
borderRadius: 999,
|
|
434
|
+
background: active ? 'rgba(255,255,255,0.22)' : 'rgba(148,163,184,0.16)',
|
|
435
|
+
color: active ? '#fff' : '#94a3b8',
|
|
436
|
+
}}
|
|
437
|
+
>
|
|
438
|
+
{item.badge}
|
|
439
|
+
</span>
|
|
440
|
+
)}
|
|
441
|
+
</button>
|
|
442
|
+
);
|
|
443
|
+
})}
|
|
444
|
+
</div>
|
|
137
445
|
</div>
|
|
138
|
-
)}
|
|
139
446
|
|
|
140
|
-
|
|
141
|
-
{
|
|
447
|
+
{/* User Footer */}
|
|
448
|
+
<div style={{ borderTop: '1px solid rgba(148,163,184,0.15)', paddingTop: 16 }}>
|
|
449
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 12, padding: '0 4px' }}>
|
|
450
|
+
<div
|
|
451
|
+
style={{
|
|
452
|
+
width: 36,
|
|
453
|
+
height: 36,
|
|
454
|
+
borderRadius: '50%',
|
|
455
|
+
background: '#1e293b',
|
|
456
|
+
border: '1px solid #334155',
|
|
457
|
+
display: 'flex',
|
|
458
|
+
alignItems: 'center',
|
|
459
|
+
justifyContent: 'center',
|
|
460
|
+
fontWeight: 700,
|
|
461
|
+
fontSize: 13,
|
|
462
|
+
color: '#60a5fa',
|
|
463
|
+
flexShrink: 0,
|
|
464
|
+
}}
|
|
465
|
+
>
|
|
466
|
+
{initials}
|
|
467
|
+
</div>
|
|
468
|
+
<div style={{ overflow: 'hidden' }}>
|
|
469
|
+
<div style={{ fontSize: 13, fontWeight: 600, whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }}>
|
|
470
|
+
{displayName}
|
|
471
|
+
</div>
|
|
472
|
+
<div style={{ fontSize: 11, color: '#94a3b8', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }}>
|
|
473
|
+
{displayEmail}
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
</div>
|
|
142
477
|
<button
|
|
143
|
-
|
|
144
|
-
onClick={
|
|
478
|
+
type="button"
|
|
479
|
+
onClick={handleSignOut}
|
|
145
480
|
style={{
|
|
146
|
-
|
|
481
|
+
width: '100%',
|
|
482
|
+
padding: '9px 12px',
|
|
147
483
|
borderRadius: 8,
|
|
148
|
-
border: '1px solid
|
|
149
|
-
background:
|
|
150
|
-
color:
|
|
151
|
-
cursor: 'pointer',
|
|
484
|
+
border: '1px solid rgba(248,113,113,0.3)',
|
|
485
|
+
background: 'rgba(239,68,68,0.1)',
|
|
486
|
+
color: '#fca5a5',
|
|
152
487
|
fontWeight: 600,
|
|
488
|
+
fontSize: 13,
|
|
489
|
+
cursor: 'pointer',
|
|
153
490
|
}}
|
|
154
491
|
>
|
|
155
|
-
|
|
492
|
+
Sign Out
|
|
156
493
|
</button>
|
|
157
|
-
|
|
158
|
-
</
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
494
|
+
</div>
|
|
495
|
+
</aside>
|
|
496
|
+
|
|
497
|
+
{/* Main Content */}
|
|
498
|
+
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
|
|
499
|
+
{/* Topbar */}
|
|
500
|
+
<header
|
|
501
|
+
style={{
|
|
502
|
+
background: '#ffffff',
|
|
503
|
+
borderBottom: '1px solid #e2e8f0',
|
|
504
|
+
padding: '18px 32px',
|
|
505
|
+
display: 'flex',
|
|
506
|
+
alignItems: 'center',
|
|
507
|
+
justifyContent: 'space-between',
|
|
508
|
+
}}
|
|
509
|
+
>
|
|
510
|
+
<div>
|
|
511
|
+
<h1 style={{ margin: 0, fontSize: 20, fontWeight: 700, textTransform: 'capitalize' }}>
|
|
512
|
+
{section === 'scim' ? 'Real-Time SCIM 2.0 Provisioning' : section.replace('-', ' ')}
|
|
513
|
+
</h1>
|
|
514
|
+
<p style={{ margin: '2px 0 0', fontSize: 13, color: '#64748b' }}>
|
|
515
|
+
Protected enterprise workspace authenticated via <strong>{domain}</strong>
|
|
516
|
+
</p>
|
|
517
|
+
</div>
|
|
518
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
|
519
|
+
<span style={{ fontSize: 12, fontWeight: 600, padding: '5px 10px', borderRadius: 999, background: '#ecfdf5', color: '#047857', border: '1px solid #a7f3d0' }}>
|
|
520
|
+
● SSO.ID Connected
|
|
521
|
+
</span>
|
|
522
|
+
<button
|
|
523
|
+
type="button"
|
|
524
|
+
onClick={() => void loadAllProtectedData()}
|
|
525
|
+
disabled={loadingData}
|
|
526
|
+
style={{
|
|
527
|
+
padding: '8px 14px',
|
|
528
|
+
borderRadius: 8,
|
|
529
|
+
border: '1px solid #cbd5e1',
|
|
530
|
+
background: '#ffffff',
|
|
531
|
+
fontWeight: 600,
|
|
532
|
+
fontSize: 13,
|
|
533
|
+
cursor: 'pointer',
|
|
534
|
+
}}
|
|
535
|
+
>
|
|
536
|
+
{loadingData ? 'Syncing...' : 'Refresh Data'}
|
|
537
|
+
</button>
|
|
538
|
+
</div>
|
|
539
|
+
</header>
|
|
540
|
+
|
|
541
|
+
<main style={{ padding: '28px 32px', maxWidth: 1240, width: '100%', boxSizing: 'border-box' }}>
|
|
542
|
+
{toast && (
|
|
543
|
+
<div
|
|
544
|
+
style={{
|
|
545
|
+
marginBottom: 20,
|
|
546
|
+
padding: '12px 16px',
|
|
547
|
+
borderRadius: 10,
|
|
548
|
+
background: toast.type === 'ok' ? '#ecfdf5' : '#fef2f2',
|
|
549
|
+
border: `1px solid ${toast.type === 'ok' ? '#a7f3d0' : '#fecaca'}`,
|
|
550
|
+
color: toast.type === 'ok' ? '#065f46' : '#991b1b',
|
|
551
|
+
fontSize: 14,
|
|
552
|
+
fontWeight: 500,
|
|
553
|
+
}}
|
|
554
|
+
>
|
|
555
|
+
{toast.text}
|
|
556
|
+
</div>
|
|
179
557
|
)}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
558
|
+
|
|
559
|
+
{/* OVERVIEW SECTION */}
|
|
560
|
+
{section === 'overview' && (
|
|
561
|
+
<>
|
|
562
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(210px, 1fr))', gap: 16, marginBottom: 24 }}>
|
|
563
|
+
{[
|
|
564
|
+
{ label: 'Organizations', count: organizations.length, target: 'organizations' as Section, color: '#2563eb' },
|
|
565
|
+
{ label: 'Organization Units', count: orgUnits.length, target: 'organization-units' as Section, color: '#7c3aed' },
|
|
566
|
+
{ label: 'Directory Users', count: users.length, target: 'users' as Section, color: '#059669' },
|
|
567
|
+
{ label: 'Security Groups', count: groups.length, target: 'groups' as Section, color: '#d97706' },
|
|
568
|
+
{ label: 'SCIM 2.0 Events', count: scimState.events.length, target: 'scim' as Section, color: '#0f172a' },
|
|
569
|
+
].map((card) => (
|
|
570
|
+
<div
|
|
571
|
+
key={card.label}
|
|
572
|
+
onClick={() => setSection(card.target)}
|
|
573
|
+
style={{
|
|
574
|
+
background: '#ffffff',
|
|
575
|
+
border: '1px solid #e2e8f0',
|
|
576
|
+
borderRadius: 14,
|
|
577
|
+
padding: '20px',
|
|
578
|
+
cursor: 'pointer',
|
|
579
|
+
boxShadow: '0 1px 2px rgba(15,23,42,0.04)',
|
|
580
|
+
}}
|
|
581
|
+
>
|
|
582
|
+
<div style={{ fontSize: 13, fontWeight: 600, color: '#64748b' }}>{card.label}</div>
|
|
583
|
+
<div style={{ fontSize: 30, fontWeight: 800, color: card.color, marginTop: 6 }}>{card.count}</div>
|
|
584
|
+
<div style={{ fontSize: 12, color: '#2563eb', marginTop: 8, fontWeight: 600 }}>Manage →</div>
|
|
585
|
+
</div>
|
|
586
|
+
))}
|
|
587
|
+
</div>
|
|
588
|
+
|
|
589
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 20 }}>
|
|
590
|
+
<div style={{ background: '#ffffff', border: '1px solid #e2e8f0', borderRadius: 14, padding: 22 }}>
|
|
591
|
+
<h3 style={{ margin: '0 0 12px', fontSize: 16 }}>Authenticated User Session</h3>
|
|
592
|
+
<div style={{ fontSize: 13, color: '#475569', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
593
|
+
<div><strong>Display Name:</strong> {displayName}</div>
|
|
594
|
+
<div><strong>Email / Subject:</strong> {displayEmail}</div>
|
|
595
|
+
<div><strong>Tenant Authority:</strong> <code>https://{domain}</code></div>
|
|
596
|
+
<div><strong>Session Mode:</strong> {spaAuthed ? 'OIDC + PKCE Browser Token' : 'Encrypted HttpOnly Server Session'}</div>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
|
|
600
|
+
<div style={{ background: '#ffffff', border: '1px solid #e2e8f0', borderRadius: 14, padding: 22 }}>
|
|
601
|
+
<h3 style={{ margin: '0 0 12px', fontSize: 16 }}>Real-Time SCIM 2.0 Endpoints</h3>
|
|
602
|
+
<div style={{ fontSize: 13, color: '#475569', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
603
|
+
<div><strong>Users Endpoint:</strong> <code>/api/scim/v2/Users</code></div>
|
|
604
|
+
<div><strong>Groups Endpoint:</strong> <code>/api/scim/v2/Groups</code></div>
|
|
605
|
+
<div><strong>Outbound Push:</strong> <code>/api/scim/sync</code></div>
|
|
606
|
+
<div><strong>Synced SCIM Users:</strong> {scimState.users.length}</div>
|
|
607
|
+
</div>
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
</>
|
|
188
611
|
)}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
612
|
+
|
|
613
|
+
{/* CREATE FORM FOR NON-OVERVIEW SECTIONS */}
|
|
614
|
+
{section !== 'overview' && (
|
|
615
|
+
<div style={{ background: '#ffffff', border: '1px solid #e2e8f0', borderRadius: 14, padding: 22, marginBottom: 22 }}>
|
|
616
|
+
<h2 style={{ margin: '0 0 14px', fontSize: 16, fontWeight: 700 }}>
|
|
617
|
+
{section === 'scim' ? 'Push Resource via Real-Time SCIM 2.0' : `Create New ${section.replace('-', ' ').replace(/s$/, '')}`}
|
|
618
|
+
</h2>
|
|
619
|
+
<form onSubmit={handleCreate} style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
|
|
620
|
+
{section === 'scim' && (
|
|
621
|
+
<select
|
|
622
|
+
value={scimPushType}
|
|
623
|
+
onChange={(e) => setScimPushType(e.target.value as 'User' | 'Group')}
|
|
624
|
+
style={{ padding: '10px 12px', borderRadius: 8, border: '1px solid #cbd5e1', fontSize: 14 }}
|
|
625
|
+
>
|
|
626
|
+
<option value="User">SCIM User</option>
|
|
627
|
+
<option value="Group">SCIM Group</option>
|
|
628
|
+
</select>
|
|
629
|
+
)}
|
|
630
|
+
|
|
631
|
+
{section === 'organization-units' && (
|
|
632
|
+
<select
|
|
633
|
+
value={selectedOrgId}
|
|
634
|
+
onChange={(e) => setSelectedOrgId(e.target.value)}
|
|
635
|
+
required
|
|
636
|
+
style={{ padding: '10px 12px', borderRadius: 8, border: '1px solid #cbd5e1', fontSize: 14, minWidth: 220 }}
|
|
637
|
+
>
|
|
638
|
+
<option value="" disabled>Select Parent Organization</option>
|
|
639
|
+
{organizations.map((o) => (
|
|
640
|
+
<option key={String(o.organizationId)} value={String(o.organizationId)}>
|
|
641
|
+
{String(o.name)} ({String(o.organizationId)})
|
|
642
|
+
</option>
|
|
643
|
+
))}
|
|
644
|
+
</select>
|
|
645
|
+
)}
|
|
646
|
+
|
|
647
|
+
<input
|
|
648
|
+
value={name}
|
|
649
|
+
onChange={(e) => setName(e.target.value)}
|
|
650
|
+
placeholder={
|
|
651
|
+
section === 'users' || (section === 'scim' && scimPushType === 'User')
|
|
652
|
+
? 'Full Name (e.g. Jane Doe)'
|
|
653
|
+
: 'Name'
|
|
654
|
+
}
|
|
655
|
+
required
|
|
656
|
+
style={{ padding: '10px 14px', borderRadius: 8, border: '1px solid #cbd5e1', fontSize: 14, minWidth: 220 }}
|
|
657
|
+
/>
|
|
658
|
+
|
|
659
|
+
{(section === 'users' || (section === 'scim' && scimPushType === 'User')) && (
|
|
660
|
+
<input
|
|
661
|
+
type="email"
|
|
662
|
+
value={email}
|
|
663
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
664
|
+
placeholder="Email address (e.g. jane@oerps.com)"
|
|
665
|
+
required
|
|
666
|
+
style={{ padding: '10px 14px', borderRadius: 8, border: '1px solid #cbd5e1', fontSize: 14, minWidth: 250 }}
|
|
667
|
+
/>
|
|
668
|
+
)}
|
|
669
|
+
|
|
670
|
+
<button
|
|
671
|
+
type="submit"
|
|
672
|
+
disabled={submitting}
|
|
673
|
+
style={{
|
|
674
|
+
padding: '10px 20px',
|
|
675
|
+
borderRadius: 8,
|
|
676
|
+
border: 'none',
|
|
677
|
+
background: '#2563eb',
|
|
678
|
+
color: '#ffffff',
|
|
679
|
+
fontWeight: 600,
|
|
680
|
+
fontSize: 14,
|
|
681
|
+
cursor: 'pointer',
|
|
682
|
+
}}
|
|
683
|
+
>
|
|
684
|
+
{submitting ? 'Saving...' : section === 'scim' ? `Push ${scimPushType} via SCIM` : '+ Create'}
|
|
685
|
+
</button>
|
|
686
|
+
</form>
|
|
687
|
+
</div>
|
|
688
|
+
)}
|
|
689
|
+
|
|
690
|
+
{/* DATA TABLE / DIRECTORY SECTION */}
|
|
691
|
+
{section !== 'overview' && (
|
|
692
|
+
<div style={{ background: '#ffffff', border: '1px solid #e2e8f0', borderRadius: 14, overflow: 'hidden' }}>
|
|
693
|
+
<div style={{ padding: '16px 22px', borderBottom: '1px solid #e2e8f0', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
694
|
+
<h3 style={{ margin: 0, fontSize: 15, fontWeight: 700 }}>
|
|
695
|
+
{section === 'scim' ? 'Synced SCIM 2.0 Directory & Live Event Stream' : `${section.replace('-', ' ').toUpperCase()} (${Array.isArray(activeData) ? activeData.length : 0})`}
|
|
696
|
+
</h3>
|
|
697
|
+
<button
|
|
698
|
+
type="button"
|
|
699
|
+
onClick={() => setShowRawJson(!showRawJson)}
|
|
700
|
+
style={{
|
|
701
|
+
padding: '6px 12px',
|
|
702
|
+
borderRadius: 6,
|
|
703
|
+
border: '1px solid #cbd5e1',
|
|
704
|
+
background: '#f8fafc',
|
|
705
|
+
fontSize: 12,
|
|
706
|
+
fontWeight: 600,
|
|
707
|
+
cursor: 'pointer',
|
|
708
|
+
}}
|
|
709
|
+
>
|
|
710
|
+
{showRawJson ? 'View Table' : 'View Raw JSON'}
|
|
711
|
+
</button>
|
|
712
|
+
</div>
|
|
713
|
+
|
|
714
|
+
{showRawJson ? (
|
|
715
|
+
<pre style={{ margin: 0, background: '#0f172a', color: '#e2e8f0', padding: 20, overflowX: 'auto', fontSize: 12.5 }}>
|
|
716
|
+
{JSON.stringify(activeData, null, 2)}
|
|
717
|
+
</pre>
|
|
718
|
+
) : section === 'organizations' ? (
|
|
719
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13.5 }}>
|
|
720
|
+
<thead>
|
|
721
|
+
<tr style={{ background: '#f8fafc', textAlign: 'left', color: '#475569' }}>
|
|
722
|
+
<th style={{ padding: '12px 20px' }}>Name</th>
|
|
723
|
+
<th style={{ padding: '12px 20px' }}>Organization ID</th>
|
|
724
|
+
<th style={{ padding: '12px 20px' }}>Status</th>
|
|
725
|
+
<th style={{ padding: '12px 20px' }}>Created By</th>
|
|
726
|
+
</tr>
|
|
727
|
+
</thead>
|
|
728
|
+
<tbody>
|
|
729
|
+
{organizations.map((o) => (
|
|
730
|
+
<tr key={String(o.organizationId)} style={{ borderTop: '1px solid #f1f5f9' }}>
|
|
731
|
+
<td style={{ padding: '12px 20px', fontWeight: 600 }}>{String(o.name)}</td>
|
|
732
|
+
<td style={{ padding: '12px 20px', fontFamily: 'monospace', color: '#475569' }}>{String(o.organizationId)}</td>
|
|
733
|
+
<td style={{ padding: '12px 20px' }}>
|
|
734
|
+
<span style={{ padding: '2px 8px', borderRadius: 999, fontSize: 11, fontWeight: 700, background: '#ecfdf5', color: '#047857' }}>
|
|
735
|
+
Active
|
|
736
|
+
</span>
|
|
737
|
+
</td>
|
|
738
|
+
<td style={{ padding: '12px 20px', color: '#64748b' }}>{String(o.createdBy || '—')}</td>
|
|
739
|
+
</tr>
|
|
740
|
+
))}
|
|
741
|
+
</tbody>
|
|
742
|
+
</table>
|
|
743
|
+
) : section === 'organization-units' ? (
|
|
744
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13.5 }}>
|
|
745
|
+
<thead>
|
|
746
|
+
<tr style={{ background: '#f8fafc', textAlign: 'left', color: '#475569' }}>
|
|
747
|
+
<th style={{ padding: '12px 20px' }}>OU Name</th>
|
|
748
|
+
<th style={{ padding: '12px 20px' }}>OU ID</th>
|
|
749
|
+
<th style={{ padding: '12px 20px' }}>Parent Organization ID</th>
|
|
750
|
+
<th style={{ padding: '12px 20px' }}>Created By</th>
|
|
751
|
+
</tr>
|
|
752
|
+
</thead>
|
|
753
|
+
<tbody>
|
|
754
|
+
{orgUnits.map((ou) => (
|
|
755
|
+
<tr key={String(ou.organizationUnitId)} style={{ borderTop: '1px solid #f1f5f9' }}>
|
|
756
|
+
<td style={{ padding: '12px 20px', fontWeight: 600 }}>{String(ou.name)}</td>
|
|
757
|
+
<td style={{ padding: '12px 20px', fontFamily: 'monospace', color: '#475569' }}>{String(ou.organizationUnitId)}</td>
|
|
758
|
+
<td style={{ padding: '12px 20px', fontFamily: 'monospace', color: '#475569' }}>{String(ou.organizationId)}</td>
|
|
759
|
+
<td style={{ padding: '12px 20px', color: '#64748b' }}>{String(ou.createdBy || '—')}</td>
|
|
760
|
+
</tr>
|
|
761
|
+
))}
|
|
762
|
+
</tbody>
|
|
763
|
+
</table>
|
|
764
|
+
) : section === 'users' ? (
|
|
765
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13.5 }}>
|
|
766
|
+
<thead>
|
|
767
|
+
<tr style={{ background: '#f8fafc', textAlign: 'left', color: '#475569' }}>
|
|
768
|
+
<th style={{ padding: '12px 20px' }}>Name</th>
|
|
769
|
+
<th style={{ padding: '12px 20px' }}>Email Address</th>
|
|
770
|
+
<th style={{ padding: '12px 20px' }}>User ID</th>
|
|
771
|
+
<th style={{ padding: '12px 20px' }}>Status</th>
|
|
772
|
+
</tr>
|
|
773
|
+
</thead>
|
|
774
|
+
<tbody>
|
|
775
|
+
{users.map((u) => (
|
|
776
|
+
<tr key={String(u.userId)} style={{ borderTop: '1px solid #f1f5f9' }}>
|
|
777
|
+
<td style={{ padding: '12px 20px', fontWeight: 600 }}>
|
|
778
|
+
{String(u.firstName || '')} {String(u.lastName || '')}
|
|
779
|
+
</td>
|
|
780
|
+
<td style={{ padding: '12px 20px', color: '#2563eb' }}>{String(u.emailAddress || u.email || '')}</td>
|
|
781
|
+
<td style={{ padding: '12px 20px', fontFamily: 'monospace', color: '#475569' }}>{String(u.userId)}</td>
|
|
782
|
+
<td style={{ padding: '12px 20px' }}>
|
|
783
|
+
<span style={{ padding: '2px 8px', borderRadius: 999, fontSize: 11, fontWeight: 700, background: u.status === 1 ? '#ecfdf5' : '#fef2f2', color: u.status === 1 ? '#047857' : '#991b1b' }}>
|
|
784
|
+
{u.status === 1 ? 'Active' : 'Inactive'}
|
|
785
|
+
</span>
|
|
786
|
+
</td>
|
|
787
|
+
</tr>
|
|
788
|
+
))}
|
|
789
|
+
</tbody>
|
|
790
|
+
</table>
|
|
791
|
+
) : section === 'groups' ? (
|
|
792
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13.5 }}>
|
|
793
|
+
<thead>
|
|
794
|
+
<tr style={{ background: '#f8fafc', textAlign: 'left', color: '#475569' }}>
|
|
795
|
+
<th style={{ padding: '12px 20px' }}>Group Name</th>
|
|
796
|
+
<th style={{ padding: '12px 20px' }}>Group ID</th>
|
|
797
|
+
<th style={{ padding: '12px 20px' }}>Created By</th>
|
|
798
|
+
</tr>
|
|
799
|
+
</thead>
|
|
800
|
+
<tbody>
|
|
801
|
+
{groups.map((g) => (
|
|
802
|
+
<tr key={String(g.groupId)} style={{ borderTop: '1px solid #f1f5f9' }}>
|
|
803
|
+
<td style={{ padding: '12px 20px', fontWeight: 600 }}>{String(g.groupName || g.name)}</td>
|
|
804
|
+
<td style={{ padding: '12px 20px', fontFamily: 'monospace', color: '#475569' }}>{String(g.groupId)}</td>
|
|
805
|
+
<td style={{ padding: '12px 20px', color: '#64748b' }}>{String(g.createdBy || '—')}</td>
|
|
806
|
+
</tr>
|
|
807
|
+
))}
|
|
808
|
+
</tbody>
|
|
809
|
+
</table>
|
|
810
|
+
) : (
|
|
811
|
+
<div style={{ padding: 20 }}>
|
|
812
|
+
<h4 style={{ margin: '0 0 10px' }}>Recent Real-Time SCIM 2.0 Events ({scimState.events.length})</h4>
|
|
813
|
+
{scimState.events.length === 0 ? (
|
|
814
|
+
<div style={{ color: '#64748b', fontSize: 13 }}>No SCIM events recorded yet. Push a user above or send a SCIM request to <code>/api/scim/v2/Users</code>.</div>
|
|
815
|
+
) : (
|
|
816
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13 }}>
|
|
817
|
+
<thead>
|
|
818
|
+
<tr style={{ background: '#f8fafc', textAlign: 'left', color: '#475569' }}>
|
|
819
|
+
<th style={{ padding: '10px 14px' }}>Direction</th>
|
|
820
|
+
<th style={{ padding: '10px 14px' }}>Resource</th>
|
|
821
|
+
<th style={{ padding: '10px 14px' }}>Operation</th>
|
|
822
|
+
<th style={{ padding: '10px 14px' }}>Summary</th>
|
|
823
|
+
<th style={{ padding: '10px 14px' }}>Timestamp</th>
|
|
824
|
+
</tr>
|
|
825
|
+
</thead>
|
|
826
|
+
<tbody>
|
|
827
|
+
{scimState.events.map((ev) => (
|
|
828
|
+
<tr key={ev.id} style={{ borderTop: '1px solid #f1f5f9' }}>
|
|
829
|
+
<td style={{ padding: '10px 14px', fontWeight: 600, textTransform: 'uppercase', color: ev.direction === 'outbound' ? '#2563eb' : '#059669' }}>
|
|
830
|
+
{ev.direction}
|
|
831
|
+
</td>
|
|
832
|
+
<td style={{ padding: '10px 14px' }}>{ev.resourceType}</td>
|
|
833
|
+
<td style={{ padding: '10px 14px', fontFamily: 'monospace' }}>{ev.operation}</td>
|
|
834
|
+
<td style={{ padding: '10px 14px' }}>{ev.summary}</td>
|
|
835
|
+
<td style={{ padding: '10px 14px', color: '#64748b' }}>{ev.timestamp}</td>
|
|
836
|
+
</tr>
|
|
837
|
+
))}
|
|
838
|
+
</tbody>
|
|
839
|
+
</table>
|
|
840
|
+
)}
|
|
841
|
+
</div>
|
|
842
|
+
)}
|
|
843
|
+
</div>
|
|
844
|
+
)}
|
|
845
|
+
</main>
|
|
846
|
+
</div>
|
|
847
|
+
</div>
|
|
208
848
|
);
|
|
209
849
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { decryptSession } from '@sso-id/nextjs';
|
|
1
3
|
import { ManagementClient, type ScimGroupResource, type ScimUserResource } from '@sso-id/node';
|
|
2
4
|
|
|
3
5
|
export function getManagementClient() {
|
|
@@ -10,6 +12,29 @@ export function getManagementClient() {
|
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
|
|
15
|
+
function readCookie(cookieHeader: string | null, name: string): string | undefined {
|
|
16
|
+
if (!cookieHeader) return undefined;
|
|
17
|
+
for (const part of cookieHeader.split(';')) {
|
|
18
|
+
const [k, ...rest] = part.trim().split('=');
|
|
19
|
+
if (k === name) return decodeURIComponent(rest.join('='));
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function requireAppAuth(req: Request): NextResponse | null {
|
|
25
|
+
const authHeader = req.headers.get('authorization') || '';
|
|
26
|
+
if (authHeader.startsWith('Bearer ') && authHeader.slice(7).trim().length > 10) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const secret = process.env.SSO_ID_SESSION_SECRET || 'dev-session-secret-change-in-production';
|
|
30
|
+
const rawCookie = readCookie(req.headers.get('cookie'), 'ssoid_next_session');
|
|
31
|
+
const session = decryptSession(rawCookie, secret);
|
|
32
|
+
if (session) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return NextResponse.json({ error: 'Authentication required. Please sign in with SSO.ID.' }, { status: 401 });
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
export interface ScimEvent {
|
|
14
39
|
id: string;
|
|
15
40
|
timestamp: string;
|
|
@@ -37,4 +62,3 @@ class ScimRealtimeStore {
|
|
|
37
62
|
|
|
38
63
|
const globalForScim = globalThis as unknown as { __scimStore?: ScimRealtimeStore };
|
|
39
64
|
export const scimStore = globalForScim.__scimStore ?? (globalForScim.__scimStore = new ScimRealtimeStore());
|
|
40
|
-
|