Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add third party apps #424

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 69 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,29 +622,29 @@ await descopeClient.management.password.configureSettings('my-tenant-id', {
You can create, update, delete or load SSO applications:

```typescript
// Create OIDC sso application
// Create OIDC SSO application
await descopeClient.management.ssoApplication.createOidcApplication({
name: 'My OIDC app name',
loginPageUrl: 'http://dummy.com/login',
});

// Create SAML sso application
// Create SAML SSO application
await descopeClient.management.ssoApplication.createSamlApplication({
name: 'My SAML app name',
loginPageUrl: 'http://dummy.com/login',
useMetadataInfo: true,
metadataUrl: 'http://dummy.com/metadata',
});

// Update OIDC sso application.
// Update OIDC SSO application.
// Update will override all fields as is. Use carefully.
await descopeClient.management.ssoApplication.updateOidcApplication({
id: 'my-app-id',
name: 'My OIDC app name',
loginPageUrl: 'http://dummy.com/login',
});

// Update SAML sso application.
// Update SAML SSO application.
// Update will override all fields as is. Use carefully.
await descopeClient.management.ssoApplication.updateSamlApplication({
id: 'my-app-id',
Expand All @@ -657,13 +657,13 @@ await descopeClient.management.ssoApplication.updateSamlApplication({
certificate: 'certificate',
});

// Tenant deletion cannot be undone. Use carefully.
// SSO application deletion cannot be undone. Use carefully.
await descopeClient.management.ssoApplication.delete('my-app-id');

// Load sso application by id
// Load SSO application by id
const app = await descopeClient.management.ssoApplication.load('my-app-id');

// Load all sso applications
// Load all SSO applications
const appsRes = await descopeClient.management.ssoApplication.loadAll();
appsRes.data.forEach((app) => {
// do something
Expand Down Expand Up @@ -1193,6 +1193,68 @@ const relations = await descopeClient.management.fga.check([
]);
```

### Manage Third Party Aplications

You can create, update, delete or load third party applications:

```typescript
// Create a third party application.
const { id, cleartext: secret } =
await descopeClient.management.thirdPartyApplication.createApplication({
name: 'my new app',
description: 'my desc',
logo: 'data:image/png;..',
approvedCallbackUrls: ['dummy.com'],
permissionsScopes: [
{
name: 'read_support',
description: 'read for support',
values: ['Support'],
},
],
attributesScopes: [
{
name: 'read_email',
description: 'read user email',
values: ['email'],
},
],
loginPageUrl: 'http://dummy.com/login',
});

// Update a third party application.
// Update will override all fields as is. Use carefully.
await descopeClient.management.thirdPartyApplication.updateApplication({
name: 'my updated app',
loginPageUrl: 'http://dummy.com/login',
approvedCallbackUrls: ['dummy.com', 'myawesomedomain.com'],
});

// third party application deletion cannot be undone. Use carefully.
await descopeClient.management.thirdPartyApplication.deleteApplication('my-app-id');

// Load third party application by id
const app = await descopeClient.management.thirdPartyApplication.loadApplication('my-app-id');

// Load all third party applications
const appsRes = await descopeClient.management.thirdPartyApplication.loadAllApplications();
appsRes.data.forEach((app) => {
// do something
});

// Search in all consents. search consents by the given app id and offset to the third page.
const consentsRes = await descopeClient.management.thirdPartyApplication.searchConsents({
appId: 'my-app',
page: 2,
});

// Delete consents. delete all user consents.
// third party application consents deletion cannot be undone. Use carefully.
await descopeClient.management.thirdPartyApplication.deleteConsents({
userIds: ['user'],
});
```

### Utils for your end to end (e2e) tests and integration tests

To ease your e2e tests, we exposed dedicated management methods,
Expand Down
2 changes: 2 additions & 0 deletions lib/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import WithAuthz from './authz';
import withSSOApplication from './ssoapplication';
import withPassword from './password';
import WithFGA from './fga';
import withThirdPartyApplication from './thirdpartyapplication';

/** Constructs a higher level Management API that wraps the functions from code-js-sdk */
const withManagement = (sdk: CoreSdk, managementKey?: string) => ({
Expand All @@ -23,6 +24,7 @@ const withManagement = (sdk: CoreSdk, managementKey?: string) => ({
accessKey: withAccessKey(sdk, managementKey),
tenant: withTenant(sdk, managementKey),
ssoApplication: withSSOApplication(sdk, managementKey),
thirdPartyApplication: withThirdPartyApplication(sdk, managementKey),
sso: withSSOSettings(sdk, managementKey),
jwt: withJWT(sdk, managementKey),
permission: withPermission(sdk, managementKey),
Expand Down
11 changes: 11 additions & 0 deletions lib/management/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ export default {
load: '/v1/mgmt/sso/idp/app/load',
loadAll: '/v1/mgmt/sso/idp/apps/load',
},
thirdPartyApplication: {
create: '/v1/mgmt/thirdparty/app/create',
update: '/v1/mgmt/thirdparty/app/update',
delete: '/v1/mgmt/thirdparty/app/delete',
load: '/v1/mgmt/thirdparty/app/load',
loadAll: '/v1/mgmt/thirdparty/apps/load',
},
thirdPartyApplicationConsents: {
delete: '/v1/mgmt/thirdparty/consents/delete',
search: '/v1/mgmt/thirdparty/consents/search',
},
sso: {
settings: '/v1/mgmt/sso/settings',
metadata: '/v1/mgmt/sso/metadata',
Expand Down
Loading
Loading