mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 09:28:55 +00:00
feat: project v2beta resource API (#9742)
# Which Problems Are Solved Resource management of projects and sub-resources was before limited by the context provided by the management API, which would mean you could only manage resources belonging to a specific organization. # How the Problems Are Solved With the addition of a resource-based API, it is now possible to manage projects and sub-resources on the basis of the resources themselves, which means that as long as you have the permission for the resource, you can create, read, update and delete it. - CreateProject to create a project under an organization - UpdateProject to update an existing project - DeleteProject to delete an existing project - DeactivateProject and ActivateProject to change the status of a project - GetProject to query for a specific project with an identifier - ListProject to query for projects and granted projects - CreateProjectGrant to create a project grant with project and granted organization - UpdateProjectGrant to update the roles of a project grant - DeactivateProjectGrant and ActivateProjectGrant to change the status of a project grant - DeleteProjectGrant to delete an existing project grant - ListProjectGrants to query for project grants - AddProjectRole to add a role to an existing project - UpdateProjectRole to change texts of an existing role - RemoveProjectRole to remove an existing role - ListProjectRoles to query for project roles # Additional Changes - Changes to ListProjects, which now contains granted projects as well - Changes to messages as defined in the [API_DESIGN](https://github.com/zitadel/zitadel/blob/main/API_DESIGN.md) - Permission checks for project functionality on query and command side - Added testing to unit tests on command side - Change update endpoints to no error returns if nothing changes in the resource - Changed all integration test utility to the new service - ListProjects now also correctly lists `granted projects` - Permission checks for project grant and project role functionality on query and command side - Change existing pre checks so that they also work resource specific without resourceowner - Added the resourceowner to the grant and role if no resourceowner is provided - Corrected import tests with project grants and roles - Added testing to unit tests on command side - Change update endpoints to no error returns if nothing changes in the resource - Changed all integration test utility to the new service - Corrected some naming in the proto files to adhere to the API_DESIGN # Additional Context Closes #9177 --------- Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
6889d6a1da
commit
7eb45c6cfd
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,347 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package zitadel.project.v2beta;
|
||||
|
||||
option go_package = "github.com/zitadel/zitadel/pkg/grpc/project/v2beta;project";
|
||||
|
||||
import "google/api/field_behavior.proto";
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
import "validate/validate.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
import "zitadel/filter/v2beta/filter.proto";
|
||||
|
||||
message ProjectGrant {
|
||||
// The unique identifier of the organization which granted the project to the granted_organization_id.
|
||||
string organization_id = 2 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629012906488334\"";
|
||||
}
|
||||
];
|
||||
// The timestamp of the granted project creation.
|
||||
google.protobuf.Timestamp creation_date = 3 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2024-12-18T07:50:47.492Z\"";
|
||||
}
|
||||
];
|
||||
// The timestamp of the last change to the granted project (e.g. creation, activation, deactivation).
|
||||
google.protobuf.Timestamp change_date = 4 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2025-01-23T10:34:18.051Z\"";
|
||||
}
|
||||
];
|
||||
// The ID of the organization the project is granted to.
|
||||
string granted_organization_id = 5 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
// The name of the organization the project is granted to.
|
||||
string granted_organization_name = 6 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"Some Organization\""
|
||||
}
|
||||
];
|
||||
// The roles of the granted project.
|
||||
repeated string granted_role_keys = 7 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "[\"role.super.man\"]"
|
||||
}
|
||||
];
|
||||
// The ID of the granted project.
|
||||
string project_id = 8 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
// The name of the granted project.
|
||||
string project_name = 9 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"ZITADEL\""
|
||||
}
|
||||
];
|
||||
// Describes the current state of the granted project.
|
||||
ProjectGrantState state = 10 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "current state of the project";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
enum ProjectGrantState {
|
||||
PROJECT_GRANT_STATE_UNSPECIFIED = 0;
|
||||
PROJECT_GRANT_STATE_ACTIVE = 1;
|
||||
PROJECT_GRANT_STATE_INACTIVE = 2;
|
||||
}
|
||||
|
||||
message Project {
|
||||
// The unique identifier of the project.
|
||||
string id = 1 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629012906488334\"";
|
||||
}
|
||||
];
|
||||
// The unique identifier of the organization the project belongs to.
|
||||
string organization_id = 2 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629012906488334\"";
|
||||
}
|
||||
];
|
||||
// The timestamp of the project creation.
|
||||
google.protobuf.Timestamp creation_date = 3 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2024-12-18T07:50:47.492Z\"";
|
||||
}
|
||||
];
|
||||
// The timestamp of the last change to the project (e.g. creation, activation, deactivation).
|
||||
google.protobuf.Timestamp change_date = 4 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2025-01-23T10:34:18.051Z\"";
|
||||
}
|
||||
];
|
||||
// The name of the project.
|
||||
string name = 5 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"ip_allow_list\"";
|
||||
}
|
||||
];
|
||||
// Describes the current state of the project.
|
||||
ProjectState state = 6 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "current state of the project";
|
||||
}
|
||||
];
|
||||
// Describes if the roles of the user should be added to the token.
|
||||
bool project_role_assertion = 7;
|
||||
// When enabled ZITADEL will check if a user has an authorization to use this project assigned when login into an application of this project.
|
||||
bool authorization_required = 8;
|
||||
// When enabled ZITADEL will check if the organization of the user, that is trying to log in, has access to this project (either owns the project or is granted).
|
||||
bool project_access_required = 9;
|
||||
// Defines from where the private labeling should be triggered.
|
||||
PrivateLabelingSetting private_labeling_setting = 10;
|
||||
|
||||
// The ID of the organization the project is granted to.
|
||||
optional string granted_organization_id = 12 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
// The name of the organization the project is granted to.
|
||||
optional string granted_organization_name = 13 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"Some Organization\""
|
||||
}
|
||||
];
|
||||
// Describes the current state of the granted project.
|
||||
GrantedProjectState granted_state = 14 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "current state of the granted project";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
enum ProjectState {
|
||||
PROJECT_STATE_UNSPECIFIED = 0;
|
||||
PROJECT_STATE_ACTIVE = 1;
|
||||
PROJECT_STATE_INACTIVE = 2;
|
||||
}
|
||||
|
||||
enum GrantedProjectState {
|
||||
GRANTED_PROJECT_STATE_UNSPECIFIED = 0;
|
||||
GRANTED_PROJECT_STATE_ACTIVE = 1;
|
||||
GRANTED_PROJECT_STATE_INACTIVE = 2;
|
||||
}
|
||||
|
||||
enum PrivateLabelingSetting {
|
||||
PRIVATE_LABELING_SETTING_UNSPECIFIED = 0;
|
||||
PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY = 1;
|
||||
PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY = 2;
|
||||
}
|
||||
|
||||
enum ProjectFieldName {
|
||||
PROJECT_FIELD_NAME_UNSPECIFIED = 0;
|
||||
PROJECT_FIELD_NAME_ID = 1;
|
||||
PROJECT_FIELD_NAME_CREATION_DATE = 2;
|
||||
PROJECT_FIELD_NAME_CHANGE_DATE = 3;
|
||||
PROJECT_FIELD_NAME_NAME = 4;
|
||||
}
|
||||
|
||||
enum ProjectGrantFieldName {
|
||||
PROJECT_GRANT_FIELD_NAME_UNSPECIFIED = 0;
|
||||
PROJECT_GRANT_FIELD_NAME_PROJECT_ID = 1;
|
||||
PROJECT_GRANT_FIELD_NAME_CREATION_DATE = 2;
|
||||
PROJECT_GRANT_FIELD_NAME_CHANGE_DATE = 3;
|
||||
}
|
||||
|
||||
enum ProjectRoleFieldName {
|
||||
PROJECT_ROLE_FIELD_NAME_UNSPECIFIED = 0;
|
||||
PROJECT_ROLE_FIELD_NAME_KEY = 1;
|
||||
PROJECT_ROLE_FIELD_NAME_CREATION_DATE = 2;
|
||||
PROJECT_ROLE_FIELD_NAME_CHANGE_DATE = 3;
|
||||
}
|
||||
|
||||
message ProjectSearchFilter {
|
||||
oneof filter {
|
||||
option (validate.required) = true;
|
||||
|
||||
ProjectNameFilter project_name_filter = 1;
|
||||
InProjectIDsFilter in_project_ids_filter = 2;
|
||||
ProjectResourceOwnerFilter project_resource_owner_filter = 3;
|
||||
ProjectGrantResourceOwnerFilter project_grant_resource_owner_filter = 4;
|
||||
ProjectOrganizationIDFilter project_organization_id_filter = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message ProjectNameFilter {
|
||||
// Defines the name of the project to query for.
|
||||
string project_name = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
max_length: 200;
|
||||
example: "\"ip_allow_list\"";
|
||||
}
|
||||
];
|
||||
// Defines which text comparison method used for the name query.
|
||||
zitadel.filter.v2beta.TextFilterMethod method = 2 [
|
||||
(validate.rules).enum.defined_only = true,
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "defines which text equality method is used";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message InProjectIDsFilter {
|
||||
// Defines the ids to query for.
|
||||
repeated string project_ids = 1 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "the ids of the projects to include"
|
||||
example: "[\"69629023906488334\",\"69622366012355662\"]";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectResourceOwnerFilter {
|
||||
// Defines the ID of organization the project belongs to query for.
|
||||
string project_resource_owner = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectGrantResourceOwnerFilter {
|
||||
// Defines the ID of organization the project grant belongs to query for.
|
||||
string project_grant_resource_owner = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectOrganizationIDFilter {
|
||||
// Defines the ID of organization the project and granted project belong to query for.
|
||||
string project_organization_id = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectGrantSearchFilter {
|
||||
oneof filter {
|
||||
option (validate.required) = true;
|
||||
|
||||
ProjectNameFilter project_name_filter = 1;
|
||||
ProjectRoleKeyFilter role_key_filter = 2;
|
||||
InProjectIDsFilter in_project_ids_filter = 3;
|
||||
ProjectResourceOwnerFilter project_resource_owner_filter = 4;
|
||||
ProjectGrantResourceOwnerFilter project_grant_resource_owner_filter = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message GrantedOrganizationIDFilter {
|
||||
// Defines the ID of organization the project is granted to query for.
|
||||
string granted_organization_id = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629023906488334\""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectRole {
|
||||
// ID of the project.
|
||||
string project_id = 1 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"69629026806489455\"";
|
||||
}
|
||||
];
|
||||
// Key of the project role.
|
||||
string key = 2 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"role.super.man\""
|
||||
}
|
||||
];
|
||||
// The timestamp of the project role creation.
|
||||
google.protobuf.Timestamp creation_date = 3 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2024-12-18T07:50:47.492Z\"";
|
||||
}
|
||||
];
|
||||
// The timestamp of the last change to the project role.
|
||||
google.protobuf.Timestamp change_date = 4 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"2025-01-23T10:34:18.051Z\"";
|
||||
}
|
||||
];
|
||||
// Display name of the project role.
|
||||
string display_name = 5 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"Super man\""
|
||||
}
|
||||
];
|
||||
// Group of the project role.
|
||||
string group = 6 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"people\""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectRoleSearchFilter {
|
||||
oneof filter {
|
||||
option (validate.required) = true;
|
||||
|
||||
ProjectRoleKeyFilter role_key_filter = 1;
|
||||
ProjectRoleDisplayNameFilter display_name_filter = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ProjectRoleKeyFilter {
|
||||
string key = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"role.super.man\""
|
||||
}
|
||||
];
|
||||
// Defines which text comparison method used for the name query.
|
||||
zitadel.filter.v2beta.TextFilterMethod method = 2 [
|
||||
(validate.rules).enum.defined_only = true
|
||||
];
|
||||
}
|
||||
|
||||
message ProjectRoleDisplayNameFilter {
|
||||
string display_name = 1 [
|
||||
(validate.rules).string = {max_len: 200},
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
example: "\"SUPER\""
|
||||
}
|
||||
];
|
||||
// Defines which text comparison method used for the name query.
|
||||
zitadel.filter.v2beta.TextFilterMethod method = 2 [
|
||||
(validate.rules).enum.defined_only = true
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user