phase-enterprise-sso-proof.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Local proof: SSO connection CRUD + productionReady flag on Doltgres.
  3. */
  4. import { initAuthCoreSdk, isAuthCoreInitialized } from '../src/services/auth-core/engine.js';
  5. import {
  6. createEngineSsoConnection,
  7. deactivateEngineSsoConnection,
  8. listEngineSsoConnections,
  9. publicSsoConnection,
  10. } from '../src/services/auth-core/sso.js';
  11. async function main() {
  12. await initAuthCoreSdk();
  13. if (!isAuthCoreInitialized()) {
  14. console.error('FAIL engine not ready');
  15. process.exit(1);
  16. }
  17. const projectId = `p_sso_proof_${Date.now().toString(36)}`;
  18. const incomplete = await createEngineSsoConnection({
  19. projectId,
  20. name: 'draft-oidc',
  21. providerType: 'oidc',
  22. config: { issuer: 'https://example.com' },
  23. });
  24. console.log('incomplete ready', incomplete.ready, publicSsoConnection(incomplete).productionReady);
  25. if (incomplete.ready) process.exit(1);
  26. const ready = await createEngineSsoConnection({
  27. projectId,
  28. name: 'okta-ready',
  29. providerType: 'oidc',
  30. domains: ['example.com'],
  31. config: {
  32. issuer: 'https://dev-example.okta.com',
  33. clientId: 'client',
  34. clientSecret: 'secret',
  35. authorizationUrl: 'https://dev-example.okta.com/oauth2/v1/authorize',
  36. tokenUrl: 'https://dev-example.okta.com/oauth2/v1/token',
  37. },
  38. });
  39. console.log('ready', ready.ready, publicSsoConnection(ready).productionReady);
  40. if (!ready.ready) process.exit(1);
  41. const listed = await listEngineSsoConnections(projectId);
  42. console.log('listed', listed.length);
  43. if (listed.length < 2) process.exit(1);
  44. await deactivateEngineSsoConnection(incomplete.id);
  45. await deactivateEngineSsoConnection(ready.id);
  46. console.log('ENTERPRISE_SSO_PROOF_OK', { projectId });
  47. }
  48. main().catch((e) => {
  49. console.error(e);
  50. process.exit(1);
  51. });