Account API handler for CRDL operations (#228)
This commit is contained in:
1 parent
2ca7e0b88e
commit
e5ec1f48b2
22 files changed
+3777
-91
No files matched your search
@@ -0,0 +1,56 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.resources.auth.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/auth;auth";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "controller/api/resources/scopes/v1/scope.proto";
|
||||
import "controller/custom_options/v1/masks.proto";
|
||||
|
||||
// Account contains all fields related to an auth Account resource
|
||||
message Account {
|
||||
// The ID of the Account
|
||||
// Output only.
|
||||
string id = 1;
|
||||
|
||||
// Scope information for this resource
|
||||
// Output only.
|
||||
resources.scopes.v1.ScopeInfo scope = 2;
|
||||
|
||||
// The auth method this account is created for.
|
||||
// Output only.
|
||||
string auth_method_id = 3 [json_name="auth_method_id"];
|
||||
|
||||
// Optional name for identification purposes
|
||||
google.protobuf.StringValue name = 4 [(custom_options.v1.mask_mapping) = {this:"name" that: "name"}];
|
||||
|
||||
// Optional user-set descripton for identification purposes
|
||||
google.protobuf.StringValue description = 5 [(custom_options.v1.mask_mapping) = {this:"description" that: "description"}];
|
||||
|
||||
// The time this resource was created
|
||||
// Output only.
|
||||
google.protobuf.Timestamp created_time = 6 [json_name="created_time"];
|
||||
|
||||
// The time this resource was last updated.
|
||||
// Output only.
|
||||
google.protobuf.Timestamp updated_time = 7 [json_name="updated_time"];
|
||||
|
||||
// Whether the resource is disabled
|
||||
google.protobuf.BoolValue disabled = 8;
|
||||
|
||||
// The type of this account. Possible values are: "password", "oidc".
|
||||
string type = 9;
|
||||
|
||||
// The attributes that are applicable for the specific Account type.
|
||||
google.protobuf.Struct attributes = 10;
|
||||
}
|
||||
|
||||
message PasswordAccountAttributes {
|
||||
// The username of this account. This is unique per auth method.
|
||||
string username = 1;
|
||||
// The password for this account.
|
||||
google.protobuf.StringValue password = 2;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.services.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api/services;services";
|
||||
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "controller/api/resources/auth/v1/account.proto";
|
||||
|
||||
service AccountService {
|
||||
|
||||
// GetAccount returns a stored Account if present. The provided request must
|
||||
// include the scope for the group being retrieved. If any of those ids are
|
||||
// missing, malformed or reference a non existing resource an error is
|
||||
// returned.
|
||||
rpc GetAccount(GetAccountRequest) returns (GetAccountResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/scopes/*/auth-methods/{auth_method_id}/accounts/{id}"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Gets a single Account"
|
||||
};
|
||||
}
|
||||
|
||||
// ListAccounts returns a list of stored accounts which exist inside the
|
||||
// auth method referenced inside the request. The request must include the
|
||||
// auth method for the account being retrieved. If the auth method is missing,
|
||||
// malformed, or references a non-existing auth method, an error is returned.
|
||||
rpc ListAccounts(ListAccountsRequest) returns (ListAccountsResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/scopes/*/auth-methods/{auth_method_id}/accounts"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Lists all accounts in a specific auth method."
|
||||
};
|
||||
}
|
||||
|
||||
// CreateAccount creates and stores an account in watchtower. The provided
|
||||
// request must include the auth method id in which the account will be created.
|
||||
// If the auth method id is missing, malformed or references a non existing
|
||||
// auth method, an error is returned. If a name is provided that is in
|
||||
// use in another account in the same auth method, an error is returned.
|
||||
rpc CreateAccount(CreateAccountRequest) returns (CreateAccountResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/scopes/*/auth-methods/{auth_method_id}/accounts"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Creates a single account in the provided auth method."
|
||||
};
|
||||
}
|
||||
|
||||
// UpdateAccount updates an existing account in watchtower. The provided account
|
||||
// must not have any read only fields set. The update mask must be included in
|
||||
// the request and contain at least 1 mutable field. To unset a field's value,
|
||||
// include the field in the update mask and don't set it in the provided
|
||||
// account. An error is returned if either the auth method or account ids are
|
||||
// missing or reference a non-existing resource. An error is also returned if the
|
||||
// request attempts to update the name to one that is already in use in this
|
||||
// auth method.
|
||||
rpc UpdateAccount(UpdateAccountRequest) returns (UpdateAccountResponse) {
|
||||
option (google.api.http) = {
|
||||
patch: "/v1/scopes/*/auth-methods/{auth_method_id}/accounts/{id}"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Updates an account."
|
||||
};
|
||||
}
|
||||
|
||||
// DeleteAccount removes an account from Watchtower. If the provided auth mehtod
|
||||
// or account ids are malformed or not provided an error is returned. No error is
|
||||
// returned if either ids reference resources that do not exist as the
|
||||
// response itself specifies if the resource existed before the DeleteAccount
|
||||
// request was received.
|
||||
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/scopes/*/auth-methods/{auth_method_id}/accounts/{id}"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Deletes an account."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetAccountRequest {
|
||||
string auth_method_id = 1;
|
||||
string id = 2;
|
||||
string view = 3;
|
||||
}
|
||||
|
||||
message GetAccountResponse {
|
||||
resources.auth.v1.Account item = 1;
|
||||
}
|
||||
|
||||
message ListAccountsRequest {
|
||||
string auth_method_id = 1;
|
||||
string view = 2;
|
||||
}
|
||||
|
||||
message ListAccountsResponse {
|
||||
repeated resources.auth.v1.Account items = 1;
|
||||
}
|
||||
|
||||
message CreateAccountRequest {
|
||||
string auth_method_id = 1;
|
||||
resources.auth.v1.Account item = 2;
|
||||
}
|
||||
|
||||
message CreateAccountResponse {
|
||||
string uri = 1;
|
||||
resources.auth.v1.Account item = 2;
|
||||
}
|
||||
|
||||
message UpdateAccountRequest {
|
||||
string auth_method_id = 1;
|
||||
string id = 2;
|
||||
resources.auth.v1.Account item = 3;
|
||||
google.protobuf.FieldMask update_mask = 4;
|
||||
}
|
||||
|
||||
message UpdateAccountResponse {
|
||||
resources.auth.v1.Account item = 1;
|
||||
}
|
||||
|
||||
message DeleteAccountRequest {
|
||||
string auth_method_id = 1;
|
||||
string id = 2;
|
||||
}
|
||||
|
||||
message DeleteAccountResponse {
|
||||
bool existed = 1;
|
||||
}
|
||||
Reference in new issue
Block a user