Documentation
¶
Index ¶
- type APIKeyPrefix
- type Action
- type AnyOfPermissions
- type Identity
- func (i *Identity) ActorAccountID() *string
- func (i *Identity) CheckAPIKeyAccess() *apierror.APIError
- func (i *Identity) CheckHasAnyPermission(perms ...Permission) *apierror.APIError
- func (i *Identity) CheckHasPermission(domain PermissionDomain, action Action) *apierror.APIError
- func (i *Identity) CheckHasRelationCapability(domain PermissionDomain, action Action) *apierror.APIError
- func (i *Identity) CheckHasRoleType(roleType constants.RoleType) *apierror.APIError
- func (i *Identity) CheckHasUserActor() *apierror.APIError
- func (i *Identity) CheckIsAPIKey() *apierror.APIError
- func (i *Identity) CheckIsAdmin() *apierror.APIError
- func (i *Identity) CheckIsAgent() *apierror.APIError
- func (i *Identity) CheckIsAssignedActor() *apierror.APIError
- func (i *Identity) CheckIsAuthenticated() *apierror.APIError
- func (i *Identity) CheckIsInternalActor() *apierror.APIError
- func (i *Identity) CheckIsSandboxMode() *apierror.APIError
- func (i *Identity) CheckIsTargetAccountSet() *apierror.APIError
- func (i *Identity) CheckIsUser() *apierror.APIError
- func (i *Identity) CheckNotSandboxMode() *apierror.APIError
- func (i *Identity) HasUserActor() bool
- func (i *Identity) IsAPIKey() bool
- func (i *Identity) IsActorSet() bool
- func (i *Identity) IsAdmin() bool
- func (i *Identity) IsAuthenticated() bool
- func (i *Identity) IsCustomerUser() bool
- func (i *Identity) IsExternalTarget() bool
- func (i *Identity) IsInternalActor() bool
- func (i *Identity) IsInternalUser() bool
- func (i *Identity) IsNotSandbox() bool
- func (i *Identity) IsRelationActor() bool
- func (i *Identity) IsRoleSet() bool
- func (i *Identity) IsSalesRep() bool
- func (i *Identity) IsSandbox() bool
- func (i *Identity) IsScanner() bool
- func (i *Identity) IsSupplierUser() bool
- func (i *Identity) IsTargetAccountSet() bool
- func (i *Identity) IsTargetCustomerAccount() bool
- func (i *Identity) IsTargetSupplierAccount() bool
- func (i *Identity) IsUnassignedUser() bool
- func (i *Identity) IsUser() bool
- func (i *Identity) ToProto() *pb.Identity
- type IdentityActor
- type IdentityActorType
- type IdentityRelationType
- type IdentityTarget
- type Permission
- type PermissionDomain
- type User
- type UserStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyPrefix ¶
type APIKeyPrefix string
const (
APIKeyPrefixSecretKey APIKeyPrefix = "mrp_sk_"
)
type AnyOfPermissions ¶
type AnyOfPermissions []Permission
AnyOfPermissions lists permissions where holding any one satisfies the requirement. API gateway endpoints declare this shape on RequiredPermissions: the coarse gate rejects callers who hold none of the listed permissions; handlers may still apply finer per-resource checks (for example unified search skips types the caller cannot read).
type Identity ¶
type Identity struct {
Type IdentityActorType
Target *IdentityTarget
Actor *IdentityActor
AccountMode constants.AccountMode
SubscriptionStatus *string
}
func GetUnauthenticatedIdentityWithMode ¶
func GetUnauthenticatedIdentityWithMode(targetAccountID *string, accountMode constants.AccountMode) *Identity
func IdentityFromProto ¶
func (*Identity) ActorAccountID ¶
ActorAccountID returns the actor's account ID, or nil if unavailable.
func (*Identity) CheckAPIKeyAccess ¶
CheckAPIKeyAccess verifies that the identity is an internal admin with a target account set — the standard gate for API key CRUD operations.
func (*Identity) CheckHasAnyPermission ¶
func (i *Identity) CheckHasAnyPermission(perms ...Permission) *apierror.APIError
CheckHasAnyPermission passes if the identity holds AT LEAST ONE of the given permissions (or is an admin). It is the coarse "OR" gate used by the api-gateway to fast-reject callers that hold none of an endpoint's declared permissions; the precise, possibly relation-dependent check still happens in the downstream service.
Relation actors (customer/supplier) always fail this check: their carried role permissions apply to their OWN account, not the target/owner account this check authorizes against, so they hold no permissions here. Customer/supplier-side capabilities (e.g. a portal order) are authorized separately via CheckHasRelationCapability, which reads those same carried permissions.
func (*Identity) CheckHasPermission ¶
func (i *Identity) CheckHasPermission(domain PermissionDomain, action Action) *apierror.APIError
CheckHasPermission checks that the identity has a specific permission. It is the single-permission case of CheckHasAnyPermission, so the gateway gate and the internal-service checks run the exact same logic.
func (*Identity) CheckHasRelationCapability ¶
func (i *Identity) CheckHasRelationCapability(domain PermissionDomain, action Action) *apierror.APIError
CheckHasRelationCapability reports whether a customer/supplier relation actor holds the given permission in their OWN account (from their carried role). Use this ONLY for explicitly customer/supplier-side authorization (e.g. a portal order create); never for operations scoped to the target/owner account — for those a relation actor holds no permissions (see CheckHasAnyPermission). Non-relation actors are rejected so callers don't accidentally use it as a general permission check.
func (*Identity) CheckHasRoleType ¶
CheckHasRoleType passes if the identity has the given role type (or is an admin, who may do anything).
func (*Identity) CheckHasUserActor ¶
CheckHasUserActor checks that the identity is an authenticated user, without requiring an assigned account. Use this for account-agnostic user endpoints (e.g. tenancy discovery) where the user may not yet have selected an account.
func (*Identity) CheckIsAPIKey ¶
CheckIsAPIKey checks that the identity is an API key
func (*Identity) CheckIsAdmin ¶
CheckIsAdmin checks that the identity is an admin
func (*Identity) CheckIsAgent ¶
func (*Identity) CheckIsAssignedActor ¶
CheckIsAssignedActor verifies that the identity is authenticated and is an internal, customer, or supplier actor (i.e. assigned to some account). This mirrors the legacy dashboard's checkIsAssignedActor.
func (*Identity) CheckIsAuthenticated ¶
CheckIsAuthenticated checks that the identity is authenticated
func (*Identity) CheckIsInternalActor ¶
CheckIsInternalActor checks that the identity is an internal user
func (*Identity) CheckIsSandboxMode ¶
CheckIsSandboxMode checks that the identity is in sandbox mode
func (*Identity) CheckIsTargetAccountSet ¶
func (*Identity) CheckIsUser ¶
CheckIsUser checks that the identity is a user
func (*Identity) CheckNotSandboxMode ¶
CheckNotSandboxMode checks that the identity is not in sandbox mode
func (*Identity) HasUserActor ¶
HasUserActor checks that the identity is an authenticated user with a valid actor ID, regardless of whether an account is assigned. Unlike IsUser, this does not require an actor account, so it suits account-agnostic user endpoints (e.g. tenancy discovery, called before an account is selected).
func (*Identity) IsAPIKey ¶
IsAPIKey checks that the identity is an API key and a valid actor was found
func (*Identity) IsActorSet ¶
IsActorSet checks that the identity is authenticated, has a valid actor, and has a valid actor account
func (*Identity) IsAdmin ¶
IsAdmin checks that the identity is authenticated, has a valid actor, a valid role, and is of type admin
func (*Identity) IsAuthenticated ¶
IsAuthenticated checks that the identity exists and is not unauthenticated
func (*Identity) IsCustomerUser ¶
IsCustomerUser checks that the identity is authenticated, has a valid actor, is of type customer
func (*Identity) IsExternalTarget ¶
IsExternalTarget checks that the identity has a valid actor, a valid actor account, and a valid target account, and that the actor's account differs from the target account
func (*Identity) IsInternalActor ¶
IsInternalActor checks that the identity has a valid actor of type internal, regardless of target account.
func (*Identity) IsInternalUser ¶
IsInternalUser checks that the identity is authenticated, has a valid actor, is of type internal, and has a valid actor account
func (*Identity) IsNotSandbox ¶
IsNotSandbox checks that the target account is not a sandbox
func (*Identity) IsRelationActor ¶
IsRelationActor reports whether the actor reaches the target account through a customer or supplier account relation rather than as an internal member. Such actors may carry their OWN-account role permissions (used by downstream services to authorize customer-side capabilities, e.g. purchase_orders:create for a portal order); those permissions apply to the actor's own account, not the target owner's. Their RoleID/RoleType are cleared (no admin bypass). The coarse gateway permission gate declares owner-side domains, so it must not reject relation actors — their access is authorized in the downstream service.
func (*Identity) IsSalesRep ¶
IsSalesRep checks that the identity is authenticated, has a valid actor, a valid role, and is of type sales rep
func (*Identity) IsScanner ¶
IsScanner checks that the identity is authenticated, has a valid actor, a valid role, and is of type scanner
func (*Identity) IsSupplierUser ¶
IsSupplierUser checks that the identity is authenticated, has a valid actor, is of type supplier
func (*Identity) IsTargetAccountSet ¶
IsTargetAccountSet returns true when a target account ID is present.
func (*Identity) IsTargetCustomerAccount ¶
IsTargetCustomerAccount returns true when the target account is a customer account relative to the actor.
func (*Identity) IsTargetSupplierAccount ¶
IsTargetSupplierAccount returns true when the target account is a supplier account relative to the actor.
func (*Identity) IsUnassignedUser ¶
IsUnassignedUser checks that the identity is authenticated, has a valid actor, and is of type unassigned
type IdentityActor ¶
type IdentityActorType ¶
type IdentityActorType string
const ( IdentityActorTypeUser IdentityActorType = "user" IdentityActorTypeAPIKey IdentityActorType = "api_key" IdentityActorTypeAgent IdentityActorType = "agent" IdentityActorTypeUnauthenticated IdentityActorType = "unauthenticated" )
type IdentityRelationType ¶
type IdentityRelationType string
const ( IdentityRelationTypeInternal IdentityRelationType = "internal" IdentityRelationTypeCustomer IdentityRelationType = "customer" IdentityRelationTypeSupplier IdentityRelationType = "supplier" IdentityRelationTypeUnassigned IdentityRelationType = "unassigned" )
func ParseIdentityRelationType ¶
func ParseIdentityRelationType(code string) (IdentityRelationType, bool)
func (IdentityRelationType) EnumValues ¶
func (t IdentityRelationType) EnumValues() []string
func (IdentityRelationType) IsValid ¶
func (t IdentityRelationType) IsValid() bool
type IdentityTarget ¶
type IdentityTarget struct {
AccountID string
RelationType *IdentityRelationType
}
type Permission ¶
type Permission struct {
Domain PermissionDomain
Action Action
}
Permission is a single required permission: a domain paired with an action. Declaring permissions with these typed constants (instead of raw "<domain>:<action>" strings) is checked by the compiler, preventing typos.
func (Permission) String ¶
func (p Permission) String() string
String renders the permission in canonical "<domain>:<action>" form.
type PermissionDomain ¶
type PermissionDomain string
const ( PermissionDomainAgents PermissionDomain = "agents" PermissionDomainAgentRuns PermissionDomain = "agent_runs" PermissionDomainAgentMemories PermissionDomain = "agent_memories" PermissionDomainAlerts PermissionDomain = "alerts" PermissionDomainAccount PermissionDomain = "self" PermissionDomainDeliveries PermissionDomain = "deliveries" PermissionDomainLocations PermissionDomain = "locations" PermissionDomainSettlements PermissionDomain = "settlements" PermissionDomainTransactions PermissionDomain = "transactions" PermissionDomainBatches PermissionDomain = "batches" PermissionDomainCarriers PermissionDomain = "carriers" PermissionDomainCustomerGroups PermissionDomain = "customer_groups" PermissionDomainCustomers PermissionDomain = "customers" PermissionDomainCustomerUsers PermissionDomain = "contacts" PermissionDomainDepartmentPicks PermissionDomain = "department_picks" PermissionDomainDepartments PermissionDomain = "departments" PermissionDomainDiscounts PermissionDomain = "discounts" PermissionDomainEdiLocations PermissionDomain = "edi_locations" PermissionDomainEdiRuns PermissionDomain = "edi_runs" PermissionDomainEmailLogs PermissionDomain = "email_logs" PermissionDomainErrorLogs PermissionDomain = "error_logs" PermissionDomainProducts PermissionDomain = "products" PermissionDomainInventory PermissionDomain = "inventory" PermissionDomainInventoryChangeLogs PermissionDomain = "inventory_change_logs" PermissionDomainInventoryLogs PermissionDomain = "inventory_logs" PermissionDomainInvoices PermissionDomain = "invoices" PermissionDomainCategories PermissionDomain = "item_categories" PermissionDomainMachines PermissionDomain = "machines" PermissionDomainMachineDowntime PermissionDomain = "machine_downtime" PermissionDomainProductionSchedules PermissionDomain = "production_schedules" PermissionDomainDemandOverrides PermissionDomain = "demand_overrides" PermissionDomainMaterials PermissionDomain = "materials" PermissionDomainOrganization PermissionDomain = "accounts" PermissionDomainPaymentTerms PermissionDomain = "payment_terms" PermissionDomainPermissions PermissionDomain = "permissions" PermissionDomainParts PermissionDomain = "parts" PermissionDomainPicks PermissionDomain = "picks" PermissionDomainReceivingOrders PermissionDomain = "receiving_orders" PermissionDomainProductGroups PermissionDomain = "product_groups" PermissionDomainItems PermissionDomain = "items" PermissionDomainProductionRuns PermissionDomain = "production_runs" PermissionDomainProductionStepTransformations PermissionDomain = "production_step_transformations" PermissionDomainProductionSteps PermissionDomain = "production_steps" PermissionDomainProductLines PermissionDomain = "product_lines" PermissionDomainProductVariations PermissionDomain = "product_variations" PermissionDomainProperties PermissionDomain = "properties" PermissionDomainPurchaseOrders PermissionDomain = "purchase_orders" PermissionDomainSuppliers PermissionDomain = "suppliers" PermissionDomainReceiving PermissionDomain = "receiving" PermissionDomainProductLineAccess PermissionDomain = "relevant_products" PermissionDomainRoles PermissionDomain = "roles" PermissionDomainSalesOrders PermissionDomain = "sales_orders" PermissionDomainTerritories PermissionDomain = "sales_rep_territories" PermissionDomainSalesTargets PermissionDomain = "sales_targets" PermissionDomainScanningStations PermissionDomain = "scanners" PermissionDomainScanningErrorLogs PermissionDomain = "scanning_error_logs" PermissionDomainShifts PermissionDomain = "shifts" PermissionDomainShipments PermissionDomain = "shipments" PermissionDomainShippingCases PermissionDomain = "shipping_cases" PermissionDomainShippingTerms PermissionDomain = "shipping_terms" PermissionDomainSupplies PermissionDomain = "supplies" PermissionDomainSystemProperties PermissionDomain = "system_properties" PermissionDomainTeamUsers PermissionDomain = "team" PermissionDomainUnits PermissionDomain = "units" PermissionDomainUnitGroups PermissionDomain = "unit_groups" PermissionDomainRequestLogs PermissionDomain = "request_logs" PermissionDomainAuditEvents PermissionDomain = "audit_events" PermissionDomainAPIKeys PermissionDomain = "api_keys" PermissionDomainSandbox PermissionDomain = "sandboxes" PermissionDomainAddresses PermissionDomain = "addresses" PermissionDomainIntegrations PermissionDomain = "integrations" PermissionDomainAdjustmentTypes PermissionDomain = "adjustment_types" PermissionDomainPriorities PermissionDomain = "priorities" PermissionDomainProductTypes PermissionDomain = "product_types" PermissionDomainJobs PermissionDomain = "jobs" PermissionDomainMessaging PermissionDomain = "messaging" )
func AllPermissionDomains ¶ added in v1.1.7
func AllPermissionDomains() []PermissionDomain
AllPermissionDomains lists every permission domain the platform recognizes, so a role's `<domain>:<action>` grant can be checked against a real domain instead of persisting an unusable one. Kept beside the constants it enumerates: adding a domain without adding it here makes that domain unassignable through the roles API.
func (PermissionDomain) IsValid ¶ added in v1.1.7
func (d PermissionDomain) IsValid() bool
IsValid reports whether the domain is one the platform recognizes.
type User ¶
type UserStatus ¶
type UserStatus string
const ( UserStatusActive UserStatus = "active" UserStatusDisabled UserStatus = "disabled" UserStatusDeleted UserStatus = "deleted" )