Skip to content

Commit

Permalink
updated sdk client
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptroger committed Nov 8, 2024
1 parent 2924b76 commit a10836f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ describe('OpenPolicyAgentEngine', () => {
credentials: [],
tokens: [],
userGroupMembers: [],
accountGroups: [],
userGroups: [],
groups: [],
userAccounts: [],
users: [],
accountGroupMembers: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const systemManagerHexPk = FIXTURE.UNSAFE_PRIVATE_KEY.Root
const ericPrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Eric
const alicePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Alice

// !! This criteria is not meant to be used alone in a policy.
// !! This criteria matches ALL incoming requests.
// !! Filters of the criteria are used to filter historical data, not incoming request
// !! If you have one policy that permits based on a group spendings
// !! It will allow anyone even if they are not in the group to spend until the aggregated limit is reached
// !! Spendings of people not in the group will not be counted against the group limit

describe('checkRateLimit', () => {
describe('rate limiting by principal', () => {
const request: Request = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const ericPrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Eric
const alicePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Alice
const davePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Dave

// !! This criteria is not meant to be used alone in a policy.
// !! This criteria matches ALL incoming requests.
// !! Filters of the criteria are used to filter historical data, not incoming request
// !! If you have one policy that permits based on a group spendings
// !! It will allow anyone even if they are not in the group to spend until the aggregated limit is reached
// !! Spendings of people not in the group will not be counted against the group limit

describe('checkSpendingLimit with overlapping legacy group entities', () => {
describe('by groupId', () => {
const request: Request = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const ericPrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Eric
const alicePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Alice
const davePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Dave

// !! This criteria is not meant to be used alone in a policy.
// !! This criteria matches ALL incoming requests.
// !! Filters of the criteria are used to filter historical data, not incoming request
// !! If you have one policy that permits based on a group spendings
// !! It will allow anyone even if they are not in the group to spend until the aggregated limit is reached
// !! Spendings of people not in the group will not be counted against the group limit
describe('checkSpendingLimit', () => {
describe('by groupId', () => {
const request: Request = {
Expand Down
2 changes: 1 addition & 1 deletion packages/armory-sdk/src/lib/data-store/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class EntityStoreClient {
*/
async push(store: { data: Partial<Entities>; signature: string }): Promise<SetEntityStoreResponse> {
const { data } = await this.dataStoreHttp.setEntities(this.config.clientId, {
data: this.populate(store.data) as any,
data: this.populate(store.data),
signature: store.signature
})

Expand Down
42 changes: 27 additions & 15 deletions packages/armory-sdk/src/lib/http/client/auth/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1692,10 +1692,22 @@ export interface EntityDataStoreDtoEntityData {
'accountGroupMembers': Array<EntityDataStoreDtoEntityDataAccountGroupMembersInner>;
/**
*
* @type {Array<EntityDataStoreDtoEntityDataGroupsInner>}
* @type {Array<EntityDataStoreDtoEntityDataAccountGroupsInner>}
* @memberof EntityDataStoreDtoEntityData
*/
'groups': Array<EntityDataStoreDtoEntityDataGroupsInner>;
'accountGroups'?: Array<EntityDataStoreDtoEntityDataAccountGroupsInner>;
/**
*
* @type {Array<EntityDataStoreDtoEntityDataAccountGroupsInner>}
* @memberof EntityDataStoreDtoEntityData
*/
'groups'?: Array<EntityDataStoreDtoEntityDataAccountGroupsInner>;
/**
*
* @type {Array<EntityDataStoreDtoEntityDataAccountGroupsInner>}
* @memberof EntityDataStoreDtoEntityData
*/
'userGroups'?: Array<EntityDataStoreDtoEntityDataAccountGroupsInner>;
/**
*
* @type {Array<EntityDataStoreDtoEntityDataAccountsInner>}
Expand All @@ -1722,6 +1734,19 @@ export interface EntityDataStoreDtoEntityDataAccountGroupMembersInner {
*/
'groupId': string;
}
/**
*
* @export
* @interface EntityDataStoreDtoEntityDataAccountGroupsInner
*/
export interface EntityDataStoreDtoEntityDataAccountGroupsInner {
/**
*
* @type {string}
* @memberof EntityDataStoreDtoEntityDataAccountGroupsInner
*/
'id': string;
}
/**
*
* @export
Expand Down Expand Up @@ -1827,19 +1852,6 @@ export interface EntityDataStoreDtoEntityDataCredentialsInner {
*/
'key': CreateClientResponseDtoPolicyEngineNodesInnerPublicKey;
}
/**
*
* @export
* @interface EntityDataStoreDtoEntityDataGroupsInner
*/
export interface EntityDataStoreDtoEntityDataGroupsInner {
/**
*
* @type {string}
* @memberof EntityDataStoreDtoEntityDataGroupsInner
*/
'id': string;
}
/**
*
* @export
Expand Down
10 changes: 8 additions & 2 deletions packages/policy-engine-shared/src/lib/schema/entity.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ export const entitiesSchema = z.object({
userAccounts: z.array(userAccountEntitySchema),
users: z.array(userEntitySchema),
accountGroupMembers: z.array(accountGroupMemberEntitySchema),
/**
* @deprecated use groups instead
*/
accountGroups: z.array(accountGroupEntitySchema).optional(),
groups: z.array(groupEntitySchema).optional(),
/**
* @deprecated use groups instead
*/
userGroups: z.array(userGroupEntitySchema).optional(),
accounts: z.array(accountEntitySchema)
accounts: z.array(accountEntitySchema),
groups: z.array(groupEntitySchema).optional()
})
3 changes: 1 addition & 2 deletions packages/policy-engine-shared/src/lib/util/entity.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ export const empty = (): Entities => ({
users: [],
accountGroupMembers: [],
accounts: [],
userGroups: [],
accountGroups: []
groups: []
})

export const removeUserById = (entities: Entities, userId: string): Entities => {
Expand Down

0 comments on commit a10836f

Please sign in to comment.