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

Bucket quota should be treated and stored as BigInts #2279

Merged
merged 15 commits into from
Jan 28, 2025
Merged
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
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "scality",
"env": {
"es2020": true
},
"parserOptions": {
"ecmaVersion": 2020
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
services:
# Label used to access the service container
redis:
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
compile:
name: Compile and upload build artifacts
needs: test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions lib/algos/list/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const MAX_STREAK_LENGTH = 100;
*/
class Skip {
/**
* @param {Object} params - skip parameters
* @param {Object} params.extension - delimiter extension used (required)
* @param {String} params.gte - current range gte (greater than or
* equal) used by the client code
* @param {Object} params - skip parameters
* @param {Object} params.extension - delimiter extension used (required)
* @param {String | string[]} params.gte - current range gte (greater than or
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is related to the fact that in MongoClientInterface we actually pass an array here: the function type was not properly defined here, leading to TS error. Having an array here is fine and expected.

* equal) used by the client code
*/
constructor(params) {
assert(params.extension);
Expand Down
23 changes: 23 additions & 0 deletions lib/auth/AuthInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ export type AuthInfoType = {
IAMdisplayName: string;
};

export type AuthorizationResults = {
isAllowed: boolean,
isImplicit: boolean,
arn: string,
action: string,
versionId?: string,
}[];

export type AccountQuota = {
account: string,
quota: bigint,
};

export type AccountInfos = {
accountQuota?: AccountQuota,
};

export type AuthV4Results = {
userInfo: AuthInfoType,
authorizationResults?: AuthorizationResults,
accountQuota: AccountQuota,
};

/**
* Class containing requester's information received from Vault
* @param {object} info from Vault including arn, canonicalID,
Expand Down
18 changes: 10 additions & 8 deletions lib/auth/Vault.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger } from 'werelogs';
import errors from '../errors';
import AuthInfo, { AuthInfoType } from './AuthInfo';
import AuthInfo, { AccountInfos, AuthInfoType, AuthorizationResults, AuthV4Results } from './AuthInfo';

/** vaultSignatureCb parses message from Vault and instantiates
* @param err - error from vault
Expand All @@ -15,15 +15,17 @@ function vaultSignatureCb(
authInfo: {
message: {
message: string,
body: {
userInfo: AuthInfoType,
authorizationResults: { [key: string]: any },
accountQuota: number,
},
body: AuthV4Results,
},
},
log: Logger,
callback: (err: Error | null, data?: any, results?: any, params?: any, infos?: any) => void,
callback: (
err: Error | null,
data?: AuthInfoType,
results?: AuthorizationResults,
params?: any,
infos?: AccountInfos,
) => void,
streamingV4Params?: any
) {
// vaultclient API guarantees that it returns:
Expand All @@ -49,7 +51,7 @@ function vaultSignatureCb(
},
});

const info = authInfo.message.body;
const info = authInfo.message.body as AuthV4Results;
const userInfo = new AuthInfo(info.userInfo);
const authorizationResults = info.authorizationResults;
const auditLog: { accountDisplayName: string, IAMdisplayName?: string } =
Expand Down
13 changes: 10 additions & 3 deletions lib/auth/backends/in_memory/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import { calculateSigningKey, hashSignature } from './vaultUtilities';
import Indexer from './Indexer';
import BaseBackend from '../base';
import { Accounts } from './types';
import { AuthInfoType, AuthV4Results } from '../../AuthInfo';

function _formatResponse(userInfoToSend: any) {
function _formatResponse(userInfo: AuthInfoType): { message: { body: AuthV4Results } } {
return {
message: {
body: { userInfo: userInfoToSend },
body: {
userInfo,
accountQuota: {
account: userInfo.canonicalID,
quota: 0n,
},
},
},
};
};
}

/**
* Class that provides a memory backend for verifying signatures and getting
Expand Down
Loading
Loading