Skip to content

Commit

Permalink
feat: add support for expiring applications (#247)
Browse files Browse the repository at this point in the history
* feat: add support for expiring applications

* test(application): update mocks

* feat(application): make name optional to support expiring apps

* feat(tokens): add expiresAt to update token request

* test(tokens): add expiresAt to mocks

* feat(applications): add conditions to access rules

* test(applications): add conditions to access rules mocks

* feat(applications): make access rules' conditions optional

* feat(applications): make access rule's container optional

Co-authored-by: Josue Leon Sarkis <jolesa97@gmail.com>
  • Loading branch information
kevinperaza and jleon15 committed Nov 17, 2022
1 parent cd3c407 commit 1cf7f16
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/types/models/applications.ts
Expand Up @@ -14,21 +14,30 @@ type TransformType = typeof TRANSFORM_TYPES[number];
interface Application extends Auditable {
id: string;
tenantId: string;
name: string;
name?: string;
key?: string;
type: ApplicationType;
permissions?: string[];
rules?: AccessRule[];
canCreateExpiringApplications?: boolean;
expiresAt?: string;
}

interface AccessRule {
description: string;
priority: number;
container: string;
container?: string;
transform: TransformType;
permissions: string[];
conditions?: Condition[];
}

type Condition = {
attribute: string;
operator: string;
value: string;
};

type CreateApplication = Pick<Application, 'name' | 'type'> &
Partial<Pick<Application, 'permissions' | 'rules'>>;

Expand Down
1 change: 1 addition & 0 deletions src/types/models/tokens.ts
Expand Up @@ -82,6 +82,7 @@ type UpdateToken<DataType = Primitive> = Partial<
| 'searchIndexes'
| 'fingerprintExpression'
| 'mask'
| 'expiresAt'
> & {
privacy: Omit<TokenPrivacy, 'classification'>;
deduplicateToken: boolean;
Expand Down
12 changes: 12 additions & 0 deletions test/applications.test.ts
Expand Up @@ -37,6 +37,8 @@ describe('Applications', () => {
name: chance.string(),
type: chance.string() as ApplicationType,
permissions: [chance.string()],
canCreateExpiringApplications: chance.bool(),
expiresAt: chance.date().toString(),
},
updatePayload: {
name: chance.string(),
Expand All @@ -63,8 +65,17 @@ describe('Applications', () => {
'reveal',
]),
permissions: [chance.string()],
conditions: [
{
attribute: chance.string(),
operator: chance.string(),
value: chance.string(),
},
],
},
],
canCreateExpiringApplications: chance.bool(),
expiresAt: chance.date().toString(),
},
updatePayload: {
name: chance.string(),
Expand All @@ -79,6 +90,7 @@ describe('Applications', () => {
'reveal',
]),
permissions: [chance.string()],
conditions: [],
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions test/tokens.test.ts
Expand Up @@ -646,6 +646,7 @@ describe('Tokens', () => {
alg: _chance.string(),
},
},
expiresAt: _chance.date().toString(),
metadata: {
camelCaseParameter: _chance.string(),
snake_case_parameter: _chance.string(),
Expand Down Expand Up @@ -709,6 +710,7 @@ describe('Tokens', () => {
},
searchIndexes: [_chance.string(), _chance.string()],
fingerprintExpression: _chance.string(),
expiresAt: _chance.date().toString(),
};
/* eslint-enable camelcase */

Expand Down

0 comments on commit 1cf7f16

Please sign in to comment.