Files
seaweedFS/weed/pb/iam.proto
Chris Lu 6bf088cec9 IAM Policy Management via gRPC (#8109)
* Add IAM gRPC service definition

- Add GetConfiguration/PutConfiguration for config management
- Add CreateUser/GetUser/UpdateUser/DeleteUser/ListUsers for user management
- Add CreateAccessKey/DeleteAccessKey/GetUserByAccessKey for access key management
- Methods mirror existing IAM HTTP API functionality

* Add IAM gRPC handlers on filer server

- Implement IamGrpcServer with CredentialManager integration
- Handle configuration get/put operations
- Handle user CRUD operations
- Handle access key create/delete operations
- All methods delegate to CredentialManager for actual storage

* Wire IAM gRPC service to filer server

- Add CredentialManager field to FilerOption and FilerServer
- Import credential store implementations in filer command
- Initialize CredentialManager from credential.toml if available
- Register IAM gRPC service on filer gRPC server
- Enable credential management via gRPC alongside existing filer services

* Regenerate IAM protobuf with gRPC service methods

* iam_pb: add Policy Management to protobuf definitions

* credential: implement PolicyManager in credential stores

* filer: implement IAM Policy Management RPCs

* shell: add s3.policy command

* test: add integration test for s3.policy

* test: fix compilation errors in policy_test

* pb

* fmt

* test

* weed shell: add -policies flag to s3.configure

This allows linking/unlinking IAM policies to/from identities
directly from the s3.configure command.

* test: verify s3.configure policy linking and fix port allocation

- Added test case for linking policies to users via s3.configure
- Implemented findAvailablePortPair to ensure HTTP and gRPC ports
  are both available, avoiding conflicts with randomized port assignments.
- Updated assertion to match jsonpb output (policyNames)

* credential: add StoreTypeGrpc constant

* credential: add IAM gRPC store boilerplate

* credential: implement identity methods in gRPC store

* credential: implement policy methods in gRPC store

* admin: use gRPC credential store for AdminServer

This ensures that all IAM and policy changes made through the Admin UI
are persisted via the Filer's IAM gRPC service instead of direct file manipulation.

* shell: s3.configure use granular IAM gRPC APIs instead of full config patching

* shell: s3.configure use granular IAM gRPC APIs

* shell: replace deprecated ioutil with os in s3.policy

* filer: use gRPC FailedPrecondition for unconfigured credential manager

* test: improve s3.policy integration tests and fix error checks

* ci: add s3 policy shell integration tests to github workflow

* filer: fix LoadCredentialConfiguration error handling

* credential/grpc: propagate unmarshal errors in GetPolicies

* filer/grpc: improve error handling and validation

* shell: use gRPC status codes in s3.configure

* credential: document PutPolicy as create-or-replace

* credential/postgres: reuse CreatePolicy in PutPolicy to deduplicate logic

* shell: add timeout context and strictly enforce flags in s3.policy

* iam: standardize policy content field naming in gRPC and proto

* shell: extract slice helper functions in s3.configure

* filer: map credential store errors to gRPC status codes

* filer: add input validation for UpdateUser and CreateAccessKey

* iam: improve validation in policy and config handlers

* filer: ensure IAM service registration by defaulting credential manager

* credential: add GetStoreName method to manager

* test: verify policy deletion in integration test
2026-01-25 13:39:30 -08:00

199 lines
4.9 KiB
Protocol Buffer

syntax = "proto3";
package iam_pb;
option go_package = "github.com/seaweedfs/seaweedfs/weed/pb/iam_pb";
option java_package = "seaweedfs.client";
option java_outer_classname = "IamProto";
//////////////////////////////////////////////////
service SeaweedIdentityAccessManagement {
// Configuration Management
rpc GetConfiguration (GetConfigurationRequest) returns (GetConfigurationResponse);
rpc PutConfiguration (PutConfigurationRequest) returns (PutConfigurationResponse);
// User Management
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse);
rpc GetUser (GetUserRequest) returns (GetUserResponse);
rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse);
rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse);
rpc ListUsers (ListUsersRequest) returns (ListUsersResponse);
// Access Key Management
rpc CreateAccessKey (CreateAccessKeyRequest) returns (CreateAccessKeyResponse);
rpc DeleteAccessKey (DeleteAccessKeyRequest) returns (DeleteAccessKeyResponse);
rpc GetUserByAccessKey (GetUserByAccessKeyRequest) returns (GetUserByAccessKeyResponse);
// Policy Management
rpc PutPolicy (PutPolicyRequest) returns (PutPolicyResponse);
rpc GetPolicy (GetPolicyRequest) returns (GetPolicyResponse);
rpc ListPolicies (ListPoliciesRequest) returns (ListPoliciesResponse);
rpc DeletePolicy (DeletePolicyRequest) returns (DeletePolicyResponse);
}
//////////////////////////////////////////////////
// Configuration Management Messages
message GetConfigurationRequest {
}
message GetConfigurationResponse {
S3ApiConfiguration configuration = 1;
}
message PutConfigurationRequest {
S3ApiConfiguration configuration = 1;
}
message PutConfigurationResponse {
}
//////////////////////////////////////////////////
// User Management Messages
message CreateUserRequest {
Identity identity = 1;
}
message CreateUserResponse {
}
message GetUserRequest {
string username = 1;
}
message GetUserResponse {
Identity identity = 1;
}
message UpdateUserRequest {
string username = 1;
Identity identity = 2;
}
message UpdateUserResponse {
}
message DeleteUserRequest {
string username = 1;
}
message DeleteUserResponse {
}
message ListUsersRequest {
}
message ListUsersResponse {
repeated string usernames = 1;
}
//////////////////////////////////////////////////
// Access Key Management Messages
message CreateAccessKeyRequest {
string username = 1;
Credential credential = 2;
}
message CreateAccessKeyResponse {
}
message DeleteAccessKeyRequest {
string username = 1;
string access_key = 2;
}
message DeleteAccessKeyResponse {
}
message GetUserByAccessKeyRequest {
string access_key = 1;
}
message GetUserByAccessKeyResponse {
Identity identity = 1;
}
//////////////////////////////////////////////////
message S3ApiConfiguration {
repeated Identity identities = 1;
repeated Account accounts = 2;
repeated ServiceAccount service_accounts = 3;
repeated Policy policies = 4;
}
message Identity {
string name = 1;
repeated Credential credentials = 2;
repeated string actions = 3;
Account account = 4;
bool disabled = 5; // User status: false = enabled (default), true = disabled
repeated string service_account_ids = 6; // IDs of service accounts owned by this user
repeated string policy_names = 7;
}
message Credential {
string access_key = 1;
string secret_key = 2;
string status = 3; // Access key status: "Active" or "Inactive"
}
message Account {
string id = 1;
string display_name = 2;
string email_address = 3;
}
// ServiceAccount represents a service account - special credentials for applications.
// Service accounts are linked to a parent user and can have restricted permissions.
message ServiceAccount {
string id = 1; // Unique identifier (e.g., "sa-xxxxx")
string parent_user = 2; // Parent identity name
string description = 3; // Optional description
Credential credential = 4; // Access key/secret for this service account
repeated string actions = 5; // Allowed actions (subset of parent)
int64 expiration = 6; // Unix timestamp, 0 = no expiration
bool disabled = 7; // Status: false = enabled (default)
int64 created_at = 8; // Creation timestamp
string created_by = 9; // Who created this service account
}
message PutPolicyRequest {
string name = 1;
string content = 2;
}
message PutPolicyResponse {
}
message GetPolicyRequest {
string name = 1;
}
message GetPolicyResponse {
string name = 1;
string content = 2;
}
message ListPoliciesRequest {
}
message ListPoliciesResponse {
repeated Policy policies = 1;
}
message DeletePolicyRequest {
string name = 1;
}
message DeletePolicyResponse {
}
message Policy {
string name = 1;
string content = 2; // JSON content of the policy
}