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

fist pass on api key crud operations #25

Merged
merged 6 commits into from
May 22, 2024
Merged

fist pass on api key crud operations #25

merged 6 commits into from
May 22, 2024

Conversation

mattkim
Copy link
Member

@mattkim mattkim commented May 9, 2024

What was changed

Fist pass on api key crud operations. Note that we these apis should accept generic principal ids and types.

  • get api keys
  • get api key
  • create api key
  • update api key
  • delete api key

This is a first pass to get ideas out there--will meditate on it and reference the other service account pr as well.

Why?

for control ops automation requirement

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?


message GetAPIKeysResponse {
// The list of API keys in ascending ids order
repeated temporal.api.cloud.identity.v1.APIKey api_keys = 1;
Copy link
Member

@anekkanti anekkanti May 10, 2024

Choose a reason for hiding this comment

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

So in the list the user won't know the owner of each of the apikeys, right?
Maybe we should add identity type and id to the APIKey message.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right let me add owner

Copy link
Member Author

Choose a reason for hiding this comment

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

done


message CreateAPIKeyRequest {
// The id of the identity to create the API key for
string identity_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Can we consider moving the identity_id and identity_type to the Spec?

Copy link
Member Author

Choose a reason for hiding this comment

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

done. and changed name to "owner_id" and "owner_type"

// Get an API key
rpc GetAPIKey (GetAPIKeyRequest) returns (GetAPIKeyResponse) {
option (google.api.http) = {
get: "/api/v1/cloud/api-keys/{api_key_id}",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
get: "/api/v1/cloud/api-keys/{api_key_id}",
get: "/api/v1/cloud/api-keys/{key_id}",

Copy link
Member

Choose a reason for hiding this comment

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

The param name should be the same as the field name.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -234,3 +234,80 @@ message GetRegionResponse {
// The temporal cloud region.
temporal.api.cloud.region.v1.Region region = 1;
}

message GetAPIKeysRequest {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
message GetAPIKeysRequest {
message GetApiKeysRequest {

We're not making other acronyms like Mtls all-upper

string resource_version = 2;
// The API key specification
APIKeySpec spec = 3;
// The current state of the API key
Copy link
Member

Choose a reason for hiding this comment

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

Since we're not using proper enumerates, may need to define in docs the string literals expected here

Copy link
Member

Choose a reason for hiding this comment

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

addressed.


message APIKey {
// The id of the API Key
string key_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
string key_id = 1;
string id = 1;

Other entities are not prefixing something to the ID here

// The id of the API Key created
string key_id = 1;
// The secret of the API Key created
string secret = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should call this token to make it clearer that this is the API key.

// The id of the owner the api key belongs to
string owner_id = 1;
// The type of the owner the api key belongs to
string owner_type = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since owner is not update-able, I think we should put the owner_id and owner_type into the APIKey message and then allow it as optional parameters into CreateAPIKey.

Copy link
Member

Choose a reason for hiding this comment

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

Talked about this offline, we will keep the owner_id and owner_type in the Spec to keep consistent with the the other apis, where all user provided info is in the spec, irrespective of their mutability.

}

message GetApiKeysResponse {
// The list of API keys in ascending ids order
Copy link
Member

@mastermanu mastermanu May 21, 2024

Choose a reason for hiding this comment

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

[Nit] "ascending ids order" --> "ascending id order"

}

message CreateApiKeyRequest {
// The spec for the API key to invite
Copy link
Member

Choose a reason for hiding this comment

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

"the API key to invite" --> "the API key to create" ?

Copy link
Member

Choose a reason for hiding this comment

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

fixed

message CreateApiKeyResponse {
// The id of the API Key created
string key_id = 1;
// The token of the API Key created
Copy link
Member

Choose a reason for hiding this comment

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

if this is sensitive/secret, should we prefix this or indicate that on the comment somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

Added a comment.

// The new API key specification
temporal.api.cloud.identity.v1.ApiKeySpec spec = 2;
// The version of the API key for which this update is intended for
// The latest version can be found in the GetAPIKey operation response
Copy link
Member

Choose a reason for hiding this comment

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

[Nit] Does the casing of this 'GetAPIKey' reference in the comment match the actual operation name casing?

Copy link
Member

Choose a reason for hiding this comment

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

Fixed.


message ApiKeySpec {
// The id of the owner to create the API key for
string owner_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

We should mark the owner_id, owner_type and expiry as immutable in the comments.

Copy link
Member

Choose a reason for hiding this comment

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

done


message ApiKeySpec {
// The id of the owner to create the API key for
string owner_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Also we should mention that the id here will be the id of the service account when the type is service account.

Copy link
Member

Choose a reason for hiding this comment

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

added comments.

// The id of the owner to create the API key for
string owner_id = 1;
// The type of the owner to create the API key for
// Possible values: user, service-account
Copy link
Member

Choose a reason for hiding this comment

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

Should we only talk about the service-account for now. We can later add user to the list when we officially support it.

Copy link
Member

Choose a reason for hiding this comment

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

never mind, we need when listing/getting apikeys of users.

@anekkanti anekkanti merged commit 6ddaddd into main May 22, 2024
3 checks passed
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.

5 participants