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

feat: add support for expiring applications #247

Merged
merged 10 commits into from Nov 17, 2022
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'> &
djejaquino marked this conversation as resolved.
Show resolved Hide resolved
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