actor

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, a Actor) context.Context

NewContext returns a new context carrying the given Actor.

Types

type Actor

type Actor interface {
	ID() string
	Type() Type
	DisplayName() string
}

Actor 表示请求发起者的最小调用源拓扑通用语:仅含 ID/Type/DisplayName 三件套。

协议特定字段(OAuth/OIDC:Email/Subject/ClientID/Realm/Roles/Scopes 与开放扩展袋 Attrs)不在该接口暴露;如业务需要,请由业务自定义 ctx 信道(如业务自家 IAM 包提供的 WithUserInfo / UserInfoFromContext)承载,servora 主仓不预设 OIDC ctx 信道。

func From added in v0.4.8

func From(ctx context.Context) (Actor, bool)

From extracts the Actor previously stored via NewContext.

func MustFrom added in v0.4.8

func MustFrom(ctx context.Context) Actor

MustFrom panics if no actor is in context — use only in trusted code paths.

type AnonymousActor

type AnonymousActor struct{}

AnonymousActor represents an unauthenticated request initiator.

func NewAnonymousActor

func NewAnonymousActor() *AnonymousActor

func (*AnonymousActor) DisplayName

func (a *AnonymousActor) DisplayName() string

func (*AnonymousActor) ID

func (a *AnonymousActor) ID() string

func (*AnonymousActor) Type

func (a *AnonymousActor) Type() Type

type ServiceActor

type ServiceActor struct {
	// contains filtered or unexported fields
}

ServiceActor represents a service-to-service caller identity (machine principal). It is used when X-Principal-Type: service is injected by the gateway.

func NewServiceActor

func NewServiceActor(id, displayName string) *ServiceActor

NewServiceActor creates a ServiceActor with the canonical three-piece identity.

func (*ServiceActor) DisplayName

func (s *ServiceActor) DisplayName() string

func (*ServiceActor) ID

func (s *ServiceActor) ID() string

func (*ServiceActor) Type

func (s *ServiceActor) Type() Type

type SystemActor

type SystemActor struct {
	// contains filtered or unexported fields
}

SystemActor represents a non-user, non-service framework / platform principal (e.g. cron jobs, internal background processes).

func NewSystemActor

func NewSystemActor(id, serviceName string) *SystemActor

NewSystemActor creates a SystemActor. id is the fully-qualified principal (e.g. "system:my-service"). serviceName 即 DisplayName 语义。

func (*SystemActor) DisplayName

func (s *SystemActor) DisplayName() string

func (*SystemActor) ID

func (s *SystemActor) ID() string

func (*SystemActor) Type

func (s *SystemActor) Type() Type

type Type

type Type string

Type identifies the kind of request initiator (generic identity, not domain model).

const (
	TypeUser      Type = "user"
	TypeSystem    Type = "system"
	TypeAnonymous Type = "anonymous"
	TypeService   Type = "service"
)

type UserActor

type UserActor struct {
	// contains filtered or unexported fields
}

UserActor is the concrete actor for an authenticated user.

func NewUserActor

func NewUserActor(id, displayName string) *UserActor

NewUserActor creates a UserActor with the canonical three-piece identity.

func (*UserActor) DisplayName

func (u *UserActor) DisplayName() string

func (*UserActor) ID

func (u *UserActor) ID() string

func (*UserActor) Type

func (u *UserActor) Type() Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL