@sso-id/cli 0.1.0 → 0.2.0

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.
Files changed (50) hide show
  1. package/bin/sso-id.mjs +128 -7
  2. package/package.json +3 -2
  3. package/templates/angular-spa/package.json +19 -0
  4. package/templates/angular-spa/src/app/app.component.ts +63 -0
  5. package/templates/angular-spa/src/app/app.config.ts +16 -0
  6. package/templates/angular-spa/src/environments/environment.ts +7 -0
  7. package/templates/dotnet-api/Program.cs +121 -0
  8. package/templates/dotnet-api/SsoIdStarter.csproj +12 -0
  9. package/templates/dotnet-api/appsettings.json +14 -0
  10. package/templates/express-api/.env.example +12 -0
  11. package/templates/express-api/README.md +8 -0
  12. package/templates/express-api/package.json +18 -0
  13. package/templates/express-api/src/server.mjs +182 -0
  14. package/templates/go-gin/.env.example +7 -0
  15. package/templates/go-gin/go.mod +6 -0
  16. package/templates/go-gin/main.go +112 -0
  17. package/templates/mobile-react-native/.env.example +5 -0
  18. package/templates/mobile-react-native/App.tsx +45 -0
  19. package/templates/mobile-react-native/package.json +11 -0
  20. package/templates/nextjs/.env.example +19 -0
  21. package/templates/nextjs/README.md +18 -0
  22. package/templates/nextjs/next.config.mjs +4 -0
  23. package/templates/nextjs/package.json +27 -0
  24. package/templates/nextjs/src/app/api/auth/[...ssoid]/route.ts +10 -0
  25. package/templates/nextjs/src/app/api/management/[resource]/route.ts +64 -0
  26. package/templates/nextjs/src/app/api/scim/sync/route.ts +60 -0
  27. package/templates/nextjs/src/app/api/scim/v2/Groups/[id]/route.ts +58 -0
  28. package/templates/nextjs/src/app/api/scim/v2/Groups/route.ts +44 -0
  29. package/templates/nextjs/src/app/api/scim/v2/Users/[id]/route.ts +89 -0
  30. package/templates/nextjs/src/app/api/scim/v2/Users/route.ts +44 -0
  31. package/templates/nextjs/src/app/layout.tsx +18 -0
  32. package/templates/nextjs/src/app/page.tsx +164 -0
  33. package/templates/nextjs/src/app/providers.tsx +16 -0
  34. package/templates/nextjs/src/lib/scim-auth.ts +12 -0
  35. package/templates/nextjs/src/lib/sso.ts +39 -0
  36. package/templates/nextjs/tsconfig.json +24 -0
  37. package/templates/php-laravel/.env.example +6 -0
  38. package/templates/php-laravel/composer.json +9 -0
  39. package/templates/php-laravel/public/index.php +34 -0
  40. package/templates/python-fastapi/.env.example +7 -0
  41. package/templates/python-fastapi/main.py +155 -0
  42. package/templates/python-fastapi/requirements.txt +6 -0
  43. package/templates/react-spa/.env.example +5 -0
  44. package/templates/react-spa/package.json +25 -0
  45. package/templates/react-spa/src/App.tsx +67 -0
  46. package/templates/react-spa/src/main.tsx +17 -0
  47. package/templates/vue-spa/.env.example +5 -0
  48. package/templates/vue-spa/package.json +20 -0
  49. package/templates/vue-spa/src/App.vue +57 -0
  50. package/templates/vue-spa/src/main.ts +14 -0
@@ -0,0 +1,57 @@
1
+ <script setup lang="ts">
2
+ import { ref, watch } from 'vue';
3
+ import { useSsoId } from '@sso-id/vue';
4
+
5
+ const API = import.meta.env.VITE_API_BASE_URL || 'http://localhost:4000';
6
+ const { isAuthenticated, user, loginWithRedirect, logout, getAccessTokenSilently } = useSsoId();
7
+ const tab = ref<'organizations' | 'organization-units' | 'users' | 'groups' | 'scim'>('organizations');
8
+ const name = ref('');
9
+ const data = ref<unknown>(null);
10
+
11
+ async function apiFetch(path: string, init?: RequestInit) {
12
+ const token = await getAccessTokenSilently();
13
+ const res = await fetch(`${API}${path}`, {
14
+ ...init,
15
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
16
+ });
17
+ return res.json();
18
+ }
19
+
20
+ async function refresh() {
21
+ if (!isAuthenticated.value) return;
22
+ data.value = await apiFetch(tab.value === 'scim' ? '/api/scim/events' : `/api/${tab.value}`);
23
+ }
24
+
25
+ watch([isAuthenticated, tab], refresh, { immediate: true });
26
+
27
+ async function createItem() {
28
+ const path = tab.value === 'scim' ? '/api/scim/push-user' : `/api/${tab.value}`;
29
+ const body = tab.value === 'users' || tab.value === 'scim' ? { email: name.value, userName: name.value, displayName: name.value } : { name: name.value };
30
+ await apiFetch(path, { method: 'POST', body: JSON.stringify(body) });
31
+ name.value = '';
32
+ await refresh();
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <main style="max-width:960px;margin:32px auto;font-family:system-ui,sans-serif;padding:16px">
38
+ <header style="display:flex;justify-content:space-between;align-items:center;margin-bottom:24px">
39
+ <h1>SSO.ID Vue 3 Starter</h1>
40
+ <button v-if="!isAuthenticated" @click="loginWithRedirect()">Sign In with SSO.ID</button>
41
+ <button v-else @click="logout()">Sign Out ({{ user?.email || user?.sub }})</button>
42
+ </header>
43
+ <section v-if="isAuthenticated">
44
+ <div style="display:flex;gap:8px;margin-bottom:16px">
45
+ <button v-for="t in ['organizations', 'organization-units', 'users', 'groups', 'scim'] as const" :key="t" @click="tab = t">
46
+ {{ t }}
47
+ </button>
48
+ </div>
49
+ <form @submit.prevent="createItem" style="display:flex;gap:8px;margin-bottom:16px">
50
+ <input v-model="name" placeholder="Name or email" required />
51
+ <button type="submit">Create</button>
52
+ </form>
53
+ <pre style="background:#0f172a;color:#e2e8f0;padding:16px;border-radius:8px">{{ JSON.stringify(data, null, 2) }}</pre>
54
+ </section>
55
+ </main>
56
+ </template>
57
+
@@ -0,0 +1,14 @@
1
+ import { createApp } from 'vue';
2
+ import { createSsoId } from '@sso-id/vue';
3
+ import App from './App.vue';
4
+
5
+ const app = createApp(App);
6
+ app.use(
7
+ createSsoId({
8
+ domain: import.meta.env.VITE_SSO_ID_DOMAIN || 'acme.sso.id',
9
+ clientId: import.meta.env.VITE_SSO_ID_CLIENT_ID || 'YOUR_CLIENT_ID',
10
+ redirectUri: import.meta.env.VITE_SSO_ID_REDIRECT_URI || `${window.location.origin}/callback`,
11
+ }),
12
+ );
13
+ app.mount('#app');
14
+