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

NSFS | Support anonymous NSFS requests #7997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naveenpaul1
Copy link
Contributor

@naveenpaul1 naveenpaul1 commented Apr 24, 2024

Explain the changes

  1. Support anonymous NSFS requests
  2. add CLI for add/updat/delete/status the anonymous account
  3. Ceph test test_post_object_wrong_bucket added to black list
  4. load_requesting_account() will load account from anonymous account. UID and GID or distinguished_name from anonymous account use for this.
  5. anonymous user to account_cache with empty access key and for that read_account_by_access_key() method is updated

Issues: Fixed #xxx / Gap #xxx

  1. Changes added to support anonymous request in namespace store
  2. remove namesapce store check in code that prevent anonymous request

Testing Instructions:

  1. Add anonymous account
    node src/cmd/manage_nsfs account add --anonymous --uid {uid} --gid {gid}
  2. Create Bucket with policy that support anonymous request
    { Effect: 'Allow', Principal: { AWS: ["*"] }, Action: ['s3:GetObject', 's3:ListBucket'], Resource: ['arn:aws:s3:::*'] }
  3. access object item using anonymous s3 request
  • Doc added/updated
  • Tests added

@naveenpaul1 naveenpaul1 marked this pull request as draft April 25, 2024 08:46
@guymguym guymguym added this to the 5.15.3 milestone Apr 25, 2024
@naveenpaul1 naveenpaul1 marked this pull request as ready for review April 25, 2024 11:21
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 2 times, most recently from 587d9f6 to 29b78b8 Compare April 28, 2024 11:10
@guymguym guymguym modified the milestones: 5.15.3, 5.15.4 May 8, 2024
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 2 times, most recently from 54c3ad4 to 658345d Compare May 9, 2024 07:49
@naveenpaul1 naveenpaul1 changed the title Support anonymous NSFS requests NSFS | Support anonymous NSFS requests May 9, 2024
@romayalon
Copy link
Contributor

Hi @naveenpaul1 :)
This week I added the test_s3_bucket_policy.js to the Non Containerized tests, I saw some anonymous tests in this tests file and skipped them, can you please check it and unskip the relevant tests?
reference - #8022

src/endpoint/s3/s3_rest.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Outdated Show resolved Hide resolved
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 6 times, most recently from e3bb799 to ee482a7 Compare May 14, 2024 11:17
@naveenpaul1 naveenpaul1 requested a review from guymguym May 14, 2024 12:20
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 3 times, most recently from e428fd8 to aeb811d Compare May 15, 2024 07:24
src/cmd/nsfs.js Outdated Show resolved Hide resolved
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 4 times, most recently from 1bd0bfd to 14d1ef3 Compare May 22, 2024 07:48
src/manage_nsfs/manage_nsfs_validations.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Outdated Show resolved Hide resolved
src/server/system_services/schemas/nsfs_account_schema.js Outdated Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_constants.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_validations.js Outdated Show resolved Hide resolved
docs/non_containerized_NSFS.md Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_validations.js Outdated Show resolved Hide resolved
src/util/native_fs_utils.js Outdated Show resolved Hide resolved
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 2 times, most recently from e2a19b4 to 6a85286 Compare May 23, 2024 11:36
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 2 times, most recently from bd3dd7f to 8ee713e Compare May 23, 2024 16:12
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
@naveenpaul1 naveenpaul1 force-pushed the anonymous_namespace_req branch 2 times, most recently from d832341 to f309093 Compare May 27, 2024 06:38
@romayalon
Copy link
Contributor

@naveenpaul1 Thanks for the hard work on this one!!!

Signed-off-by: naveenpaul1 <napaul@redhat.com>
* (instead of flags) and return its content
* @param {object[]} access_keys
*/
function is_anonymous(access_keys) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to has_access_keys please


Anonymous requests are those sent without access and secret key and Noobaa NSFS allow it with supporting bucket policy. Users have to create an anonymous account before accessing the resources. Noobaa uses anonymous account's uid and gid or user(distinguished_name) for accessing bucket storage paths. Noobaa can have one anonymous account. Commands for creating anonumous account are
```
node src/cmd/manage_nsfs account add --anonymous --uid {uid} --gid {gid}
Copy link
Contributor

Choose a reason for hiding this comment

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

can someone create/update a regular account called anonymous? we need to block it if so

// ANONYMOUS: cannot work without bucket, cannot work on namespace bucket (?)
// ANONYMOUS: cannot work without bucket.
// Return if the acount is anonymous
const is_anon = !(token && token.access_key);
Copy link
Contributor

Choose a reason for hiding this comment

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

this causing s3 requests with access key empty and secret key non empty to make anon requests instead of failing like happens in AWS

@@ -96,8 +96,8 @@ class BucketSpaceFS extends BucketSpaceSimpleFS {

async read_account_by_access_key({ access_key }) {
try {
if (!access_key) throw new Error('no access key');
const iam_path = this._get_access_keys_config_path(access_key);
const iam_path = access_key === '' ? this._get_account_config_path(config.NC_ANON_ACCOUNT_NAME) :
Copy link
Member

Choose a reason for hiding this comment

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

Using empty string or even undefined can be accidental and we really don't want to allow that.
Lets do this - define a new const anonymous_access_key = Symbol('anonymous_access_key') in object_sdk.
Then we should use this symbol as the key to the cache, but be explicit about it and not implicit.

@@ -207,19 +207,17 @@ class ObjectSDK {
async load_requesting_account(req) {
try {
const token = this.get_auth_token();
if (!token) return;
const is_anon = !(token && token.access_key);
Copy link
Member

Choose a reason for hiding this comment

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

also here we want to only check !token and not assume empty access key is also anon, right?

this.requesting_account = await account_cache.get_with_cache({
bucketspace: this._get_bucketspace(),
access_key: token.access_key,
access_key: is_anon ? '' : token.access_key,
Copy link
Member

Choose a reason for hiding this comment

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

Per the suggestion to use symbol above -

Suggested change
access_key: is_anon ? '' : token.access_key,
access_key: token ? token.access_key : anonymous_access_key,

```
or
```
node src/cmd/manage_nsfs account add --anonymous --user {user}
Copy link
Member

Choose a reason for hiding this comment

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

change all calls from manage_nsfs to noobaa-cli -

Suggested change
node src/cmd/manage_nsfs account add --anonymous --user {user}
noobaa-cli account add --anonymous --user {user}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

standalone nsfs: process getting crashed when we hit anonymous tests
4 participants