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 | NC | IAM Service - Phase 1 (dummy impls) #8009

Merged
merged 1 commit into from May 19, 2024

Conversation

shirady
Copy link
Contributor

@shirady shirady commented May 5, 2024

Explain the changes

  1. Add the boilerplate implementation of the IAM service based on the S3 and STS services that were already implemented.
  2. Add basic tests (only test the return structure).

Issues:

Gaps:

  1. Check the error by AWS when the request doesn't contain the header 'application/x-www-form-urlencoded'.
  2. Move the requesting account to be called from the accountSpace (currently it is copied).
  3. Refactor endpoint.js and nsfs.js so the both will reuse the config.js values (and not process.env in some cases).
  4. Consolidate the calls of the functions http_utils.authorize_session_token(req, headers_options); and authenticate_request(req); in one place and reuse in S3, STS and IAM.
  5. In nb.d define the params in every action (even as an object inline).
  6. Implement the simple flow in account SDK.
  7. Parsing and validating the params (for example: username).
  8. Remove unused errors that were copied from STS errors.

Testing Instructions:

Unit Tests

Those tests are basic and test the return structure of the API.
sudo npx jest test_accountspace_fs.test.js (without sudo will also work, but later tests in future PR will need the root permissions).

Manual Tests

These tests will only test the flow of the service (without any changes in the config files).

  1. Create the root user account with the CLI: sudo node src/cmd/manage_nsfs account add --name shira-1002 --new_buckets_path /tmp/nsfs_root1 --access_key <access-key> --secret_key <secret-key> --uid <uid> --gid <gid>
    Note: before creating the account need to give permission to the new_buckets_path: chmod 777 /tmp/nsfs_root1.
  2. Start the NSFS server with: sudo node src/cmd/nsfs --debug 5 --https_port_iam 7005
    Note: before starting the server please add this line: process.env.NOOBAA_LOG_LEVEL = 'nsfs'; in the endpoint.js (before the condition if (process.env.NOOBAA_LOG_LEVEL) {)
  3. Create the alias for IAM service: alias s3-nc-user-1-iam='AWS_ACCESS_KEY_ID=<acess-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:7005'.
  4. Use AWS CLI to send requests to the IAM service, for example: s3-nc-user-1-iam iam create-user --user-name Bob --path '/division_abc/subdivision_xyz/' (more examples in the comment below)

Note: For checking the error parsing: comment out the return part in create_user and add throw new IamError(IamError.AccessDeniedException);.

  • Doc added/updated
  • Tests added

@shirady
Copy link
Contributor Author

shirady commented May 5, 2024

Manual Tests examples:

Note: assuming that you already created the alias s3-nc-user-1-iam as mentioned in the PR description in the Testing Instructions part.

user (CRUD)

  • s3-nc-user-1-iam iam create-user --user-name Bob --path '/division_abc/subdivision_xyz/'
    • s3-nc-user-1-iam iam get-user (without --user-name flag)
  • s3-nc-user-1-iam iam get-user --user-name Bob
  • s3-nc-user-1-iam iam update-user --user-name Bob --new-user-name Robert --new-path '/division_abc/subdivision_abc/'
  • s3-nc-user-1-iam iam delete-user --user-name Bob
  • s3-nc-user-1-iam iam list-users

access keys (CRUD)

  • s3-nc-user-1-iam iam create-access-key --user-name Bob
  • s3-nc-user-1-iam iam get-access-key-last-used --access-key-id <access-key> (currently of the root account)
  • s3-nc-user-1-iam iam update-access-key --access-key-id <access-key> --user-name Bob --status Inactive
  • s3-nc-user-1-iam iam delete-access-key --access-key-id <access-key> --user-name Bob
  • s3-nc-user-1-iam iam list-access-keys --user-name Bob

@shirady shirady force-pushed the nsfs-iam-account branch 7 times, most recently from 8bfecda to 8c583b1 Compare May 7, 2024 08:19
@guymguym guymguym added this to the 5.16.z milestone May 8, 2024
@shirady shirady force-pushed the nsfs-iam-account branch 4 times, most recently from 531bf8b to b07b480 Compare May 15, 2024 14:58
@guymguym guymguym changed the title NSFS | NC | IAM Service NSFS | NC | IAM Service - Phase 1 (dummy impls) May 16, 2024
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

approving with few small comments.
also I think this feature deserves its own design doc in docs/design/iam.md
we don't need all the details in that doc, but we should start pouring content into it to describe our rational, implementation, limitations, roadmap. I would already create it with this PR, even with a single paragraph if no more time.

src/endpoint/iam/ops/iam_get_user.js Outdated Show resolved Hide resolved
src/endpoint/iam/iam_utils.js Outdated Show resolved Hide resolved
src/util/http_utils.js Outdated Show resolved Hide resolved
@shirady shirady merged commit cea377d into noobaa:master May 19, 2024
10 checks passed
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.

None yet

2 participants