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

Add Namespace Management CLI Commands #14

Merged
merged 10 commits into from
Aug 1, 2023
Merged

Add Namespace Management CLI Commands #14

merged 10 commits into from
Aug 1, 2023

Conversation

CohenQU
Copy link
Contributor

@CohenQU CohenQU commented Jul 24, 2023

This commit adds several new commands to the CLI for managing namespaces. The commands added include:

  • Register a new namespace
  • Delete a namespace
  • List all namespaces
  • Get a specific namespace This commit also adds the necessary flag definitions and configurations for each command.

In addition, the commit includes the implementation of JWT-based authentication when registering a namespace. This includes handling of JSON Web Key Sets (JWKS), signing/verification of payloads, nonce generation, and HTTP request/response handling.

The code also includes functions for loading and saving signatures to/from a file, and for loading ECDSA public/private keys from PEM and JWKS formats.

This commit adds several new commands to the CLI for managing namespaces. The commands added include:

- Register a new namespace
- Delete a namespace
- List all namespaces
- Get a specific namespace
This commit also adds the necessary flag definitions and configurations for each command.

In addition, the commit includes the implementation of JWT-based authentication when registering a namespace. This includes handling of JSON Web Key Sets (JWKS), signing/verification of payloads, nonce generation, and HTTP request/response handling.

The code also includes functions for loading and saving signatures to/from a file, and for loading ECDSA public/private keys from PEM and JWKS formats.
@CohenQU CohenQU requested a review from jhiemstrawisc July 24, 2023 14:56
@CohenQU CohenQU marked this pull request as draft July 24, 2023 14:59
CohenQU added 5 commits July 24, 2023 10:06
- Checked error returns from 'viper.BindPFlag' calls for robust error handling.
- Commented out unused functions 'writeSignatureToFile', 'loadSignatureFromFile', 'verifySignature' to prevent 'unused' linting errors.
- Utilized the err variable after client.Do(req) call to prevent ineffectual assignment.
@CohenQU CohenQU marked this pull request as ready for review July 24, 2023 16:01
Copy link
Collaborator

@bbockelm bbockelm left a comment

Choose a reason for hiding this comment

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

A few cleanup items requested; comments are inline.

The big picture item is to switch to using the JWT library that's already used in the client. See:

https://github.com/PelicanPlatform/pelican/blob/main/origin_ui/origin.go#L148-L165

That should actually decrease the size of the PR quite a bit.

cmd/namespace_registry.go Outdated Show resolved Hide resolved
cmd/namespace_registry.go Outdated Show resolved Hide resolved
cmd/namespace_registry.go Outdated Show resolved Hide resolved
cmd/namespace_registry.go Outdated Show resolved Hide resolved
cmd/namespace_registry.go Outdated Show resolved Hide resolved
cmd/namespace_registry.go Show resolved Hide resolved
cmd/root.go Show resolved Hide resolved
@CohenQU CohenQU requested a review from bbockelm July 31, 2023 14:29
Copy link
Collaborator

@bbockelm bbockelm left a comment

Choose a reason for hiding this comment

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

A few review comments - but given we're short on time I'll merge anyway:

  1. Better to unmarshal into structs instead of map[string]interface{}; that will ensure the expected keys are present.
  2. Elsewhere in the code, we've been using CamelCase instead of underscores.
  3. I suspect there's a better way to handle the JWKS serialization besides converting it to a map. A follow-up might be to dig through the jwk library to see if there's some serialization routines we can reuse from there.

@bbockelm bbockelm merged commit 696f00c into main Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants