mirror of
https://github.com/hanzoai/ca.git
synced 2026-11-03 18:08:27 +00:00
386 lines
11 KiB
Go
386 lines
11 KiB
Go
// Code generated by protoc-gen-go-mock. DO NOT EDIT.
|
|
|
|
package pb
|
|
|
|
import (
|
|
context "context"
|
|
"net/http"
|
|
|
|
"github.com/effective-security/porto/xhttp/httperror"
|
|
"github.com/effective-security/porto/xhttp/marshal"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
// RequestAllocator defines constructor to allocate Protobuf request
|
|
type RequestAllocator func() any
|
|
|
|
// CheckAccessFunc defines function to check access rights for the HTTP request
|
|
type CheckAccessFunc func(ctx context.Context, req any, action string) error
|
|
|
|
// MethodInfo provides info about RPC method
|
|
type MethodInfo struct {
|
|
Allocator RequestAllocator
|
|
AllowedRoles []string
|
|
Scopes []string
|
|
CliCmd string
|
|
RefreshInterval uint32
|
|
}
|
|
|
|
// UnmarshalRequest unmarshals JSON body of HTTP request to protobuf request
|
|
func UnmarshalRequest(w http.ResponseWriter, r *http.Request) (any, *MethodInfo, error) {
|
|
info := methods[r.URL.Path]
|
|
if info == nil {
|
|
err := httperror.NotFound("path not found: %s", r.URL.Path)
|
|
marshal.WriteJSON(w, r, err)
|
|
return nil, nil, err
|
|
}
|
|
|
|
req := info.Allocator()
|
|
err := marshal.DecodeBody(w, r, req)
|
|
if err != nil {
|
|
// DecodeBody writes error response and logs, if invalid request
|
|
return nil, nil, err
|
|
}
|
|
return req, info, nil
|
|
}
|
|
|
|
// GetMethodInfo returns MethodInfo
|
|
func GetMethodInfo(method string) *MethodInfo {
|
|
return methods[method]
|
|
}
|
|
|
|
// GetMethodsInfo returns map of methods
|
|
func GetMethodsInfo() map[string]*MethodInfo {
|
|
return methods
|
|
}
|
|
|
|
// GetMethodAliases returns map of method CLI commands to method names
|
|
func GetMethodAliases() map[string]string {
|
|
res := make(map[string]string, len(methods))
|
|
for fn, method := range methods {
|
|
if method.CliCmd != "" {
|
|
res[method.CliCmd] = fn
|
|
}
|
|
}
|
|
return res
|
|
}
|
|
|
|
// methods defines map for routes
|
|
var methods = map[string]*MethodInfo{
|
|
|
|
Auth_GetProviders_FullMethodName: {
|
|
Allocator: func() any { return new(AuthProvidersRequest) },
|
|
CliCmd: "auth providers",
|
|
},
|
|
|
|
Auth_GetUserToken_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "auth user",
|
|
},
|
|
|
|
Auth_RevokeToken_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "auth revoke",
|
|
},
|
|
|
|
Auth_Caller_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "auth caller",
|
|
},
|
|
|
|
Auth_ExchangeCode_FullMethodName: {
|
|
Allocator: func() any { return new(ExchangeCodeRequest) },
|
|
},
|
|
|
|
Auth_SelectOrg_FullMethodName: {
|
|
Allocator: func() any { return new(SelectOrgRequest) },
|
|
CliCmd: "auth org",
|
|
},
|
|
|
|
Auth_AuthenticateAPIKey_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
},
|
|
|
|
Auth_GetAllowedMethods_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "auth allowed",
|
|
},
|
|
|
|
Auth_GetCallerScope_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "auth scope",
|
|
},
|
|
|
|
CA_RegisterIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(RegisterIssuerRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_UpdateIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(UpdateIssuerRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_ImportIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(ImportIssuerRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_ActivateIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(ActivateIssuerRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_GetIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(GetIssuerRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"ca:read"},
|
|
},
|
|
|
|
CA_ListIssuers_FullMethodName: {
|
|
Allocator: func() any { return new(ListIssuersRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"ca:read"},
|
|
},
|
|
|
|
CA_RegisterRoot_FullMethodName: {
|
|
Allocator: func() any { return new(RegisterRootRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_ListRoots_FullMethodName: {
|
|
Allocator: func() any { return new(ListRootsRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"ca:read"},
|
|
},
|
|
|
|
CA_RegisterProfile_FullMethodName: {
|
|
Allocator: func() any { return new(RegisterProfileRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_GetProfile_FullMethodName: {
|
|
Allocator: func() any { return new(GetProfileRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"ca:read"},
|
|
},
|
|
|
|
CA_ListProfiles_FullMethodName: {
|
|
Allocator: func() any { return new(ListProfilesRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"ca:read"},
|
|
},
|
|
|
|
CA_DeleteProfile_FullMethodName: {
|
|
Allocator: func() any { return new(DeleteProfileRequest) },
|
|
AllowedRoles: []string{"Admin"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_SignCertificate_FullMethodName: {
|
|
Allocator: func() any { return new(SignCertificateRequest) },
|
|
AllowedRoles: []string{"User", "APIKey"},
|
|
Scopes: []string{"certs:issue"},
|
|
},
|
|
|
|
CA_GetCertificate_FullMethodName: {
|
|
Allocator: func() any { return new(GetCertificateRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"certs:read"},
|
|
},
|
|
|
|
CA_ListCertificates_FullMethodName: {
|
|
Allocator: func() any { return new(ListCertificatesRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"certs:read"},
|
|
},
|
|
|
|
CA_UpdateCertificateLabel_FullMethodName: {
|
|
Allocator: func() any { return new(UpdateCertificateLabelRequest) },
|
|
AllowedRoles: []string{"User", "APIKey"},
|
|
Scopes: []string{"certs:issue"},
|
|
},
|
|
|
|
CA_RevokeCertificate_FullMethodName: {
|
|
Allocator: func() any { return new(RevokeCertificateRequest) },
|
|
AllowedRoles: []string{"User", "APIKey", "Security"},
|
|
Scopes: []string{"certs:revoke"},
|
|
},
|
|
|
|
CA_ListRevokedCertificates_FullMethodName: {
|
|
Allocator: func() any { return new(ListRevokedCertificatesRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"certs:read"},
|
|
},
|
|
|
|
CA_GetCRL_FullMethodName: {
|
|
Allocator: func() any { return new(GetCrlRequest) },
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"certs:read"},
|
|
},
|
|
|
|
CA_PublishCrls_FullMethodName: {
|
|
Allocator: func() any { return new(PublishCrlsRequest) },
|
|
AllowedRoles: []string{"Admin", "Security", "APIKey"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CA_SignOCSP_FullMethodName: {
|
|
Allocator: func() any { return new(OCSPRequest) },
|
|
AllowedRoles: []string{"Admin", "Security"},
|
|
Scopes: []string{"ca:write"},
|
|
},
|
|
|
|
CIS_GetRoots_FullMethodName: {
|
|
Allocator: func() any { return new(GetRootsRequest) },
|
|
},
|
|
|
|
CIS_GetIssuer_FullMethodName: {
|
|
Allocator: func() any { return new(GetIssuerInfoRequest) },
|
|
},
|
|
|
|
CIS_GetCertificate_FullMethodName: {
|
|
Allocator: func() any { return new(GetCertificateInfoRequest) },
|
|
},
|
|
|
|
CIS_GetCertificateStatus_FullMethodName: {
|
|
Allocator: func() any { return new(GetCertificateInfoRequest) },
|
|
},
|
|
|
|
CIS_GetCRL_FullMethodName: {
|
|
Allocator: func() any { return new(GetCrlRequest) },
|
|
},
|
|
|
|
Orgs_RegisterOrg_FullMethodName: {
|
|
Allocator: func() any { return new(RegisterOrgRequest) },
|
|
CliCmd: "org register",
|
|
},
|
|
|
|
Orgs_GetOrg_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "org get",
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"org:read"},
|
|
},
|
|
|
|
Orgs_UpdateOrg_FullMethodName: {
|
|
Allocator: func() any { return new(UpdateOrgRequest) },
|
|
CliCmd: "org update",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_DeleteOrg_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "org delete",
|
|
AllowedRoles: []string{"Owner"},
|
|
},
|
|
|
|
Orgs_GetUserOrgs_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "org list",
|
|
},
|
|
|
|
Orgs_GetUserMemberships_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "org access",
|
|
AllowedRoles: []string{"Viewer"},
|
|
},
|
|
|
|
Orgs_GetMembers_FullMethodName: {
|
|
Allocator: func() any { return new(GetMembersRequest) },
|
|
CliCmd: "member list",
|
|
AllowedRoles: []string{"Support", "Security"},
|
|
},
|
|
|
|
Orgs_AddMember_FullMethodName: {
|
|
Allocator: func() any { return new(AddMemberRequest) },
|
|
CliCmd: "member add",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_ChangeMemberRole_FullMethodName: {
|
|
Allocator: func() any { return new(ChangeMemberRoleRequest) },
|
|
CliCmd: "member role",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_DeleteMember_FullMethodName: {
|
|
Allocator: func() any { return new(DeleteMemberRequest) },
|
|
CliCmd: "member delete",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_DeleteInvite_FullMethodName: {
|
|
Allocator: func() any { return new(DeleteInviteRequest) },
|
|
CliCmd: "member invite delete",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_RegisterProject_FullMethodName: {
|
|
Allocator: func() any { return new(RegisterProjectRequest) },
|
|
CliCmd: "project register",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_UpdateProject_FullMethodName: {
|
|
Allocator: func() any { return new(UpdateProjectRequest) },
|
|
CliCmd: "project update",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_GetProject_FullMethodName: {
|
|
Allocator: func() any { return new(GetProjectRequest) },
|
|
CliCmd: "project get",
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"project:read"},
|
|
},
|
|
|
|
Orgs_ListProjects_FullMethodName: {
|
|
Allocator: func() any { return new(ListProjectsRequest) },
|
|
CliCmd: "project list",
|
|
AllowedRoles: []string{"Viewer", "APIKey"},
|
|
Scopes: []string{"org:read"},
|
|
},
|
|
|
|
Orgs_DeleteProject_FullMethodName: {
|
|
Allocator: func() any { return new(DeleteProjectRequest) },
|
|
CliCmd: "project delete",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_CreateAPIKey_FullMethodName: {
|
|
Allocator: func() any { return new(CreateAPIKeyRequest) },
|
|
CliCmd: "api-key create",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_ListAPIKeys_FullMethodName: {
|
|
Allocator: func() any { return new(ListAPIKeysRequest) },
|
|
CliCmd: "api-key list",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Orgs_DeleteAPIKey_FullMethodName: {
|
|
Allocator: func() any { return new(APIKeyRequest) },
|
|
CliCmd: "api-key delete",
|
|
AllowedRoles: []string{"Admin"},
|
|
},
|
|
|
|
Status_Version_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "version",
|
|
},
|
|
|
|
Status_Server_FullMethodName: {
|
|
Allocator: func() any { return new(emptypb.Empty) },
|
|
CliCmd: "server",
|
|
RefreshInterval: 10,
|
|
},
|
|
}
|