api_access_grant

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveManagedRole

func RemoveManagedRole(db *gorm.DB, principal PrincipalRef) (uint, error)

RemoveManagedRole deletes a principal's internal quick-grant role and all of its associations. Callers already inside a Core transaction can use it when the principal becomes ineligible for managed grants.

Types

type AccessGrantResponse

type AccessGrantResponse struct {
	PrincipalType  models.APIPrincipalType `json:"principal_type"`
	PrincipalID    uint                    `json:"principal_id"`
	PrincipalLabel string                  `json:"principal_label"`
	APIServiceID   uint                    `json:"api_service_id"`
	APIServiceName string                  `json:"api_service_name"`
	Configured     *ConfiguredGrant        `json:"configured,omitempty"`
	Effective      EffectiveAccess         `json:"effective"`
	Sources        []AccessSource          `json:"sources"`
}

type AccessSource

type AccessSource string
const (
	AccessSourceManaged    AccessSource = "managed"
	AccessSourceCustomRole AccessSource = "custom_role"
	AccessSourceUserGroup  AccessSource = "user_group"
)

type ConfiguredGrant

type ConfiguredGrant struct {
	PrincipalType models.APIPrincipalType `json:"principal_type"`
	PrincipalID   uint                    `json:"principal_id"`
	APIServiceID  uint                    `json:"api_service_id"`
	Scope         GrantScope              `json:"scope"`
	RouteIDs      []uint                  `json:"route_ids"`
}

type DeleteRequest

type DeleteRequest struct {
	PrincipalType models.APIPrincipalType `uri:"principal_type" binding:"required"`
	PrincipalID   uint                    `uri:"principal_id" binding:"required"`
	APIServiceID  uint                    `uri:"service_id" binding:"required"`
}

type EffectiveAccess

type EffectiveAccess struct {
	Scope    GrantScope `json:"scope"`
	RouteIDs []uint     `json:"route_ids"`
}

type EffectiveAccessFinder

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

EffectiveAccessFinder projects the same role set and invoke decision used by the Agent into an admin-readable service access response.

func NewEffectiveAccessFinder

func NewEffectiveAccessFinder(query dao.AdminQuery) *EffectiveAccessFinder

func (*EffectiveAccessFinder) Find

func (f *EffectiveAccessFinder) Find(ctx context.Context, principal PrincipalRef, serviceID uint) (EffectiveAccess, error)

func (*EffectiveAccessFinder) FindResponse

func (f *EffectiveAccessFinder) FindResponse(ctx context.Context, principal PrincipalRef, serviceID uint) (AccessGrantResponse, error)

type EffectiveRequest

type EffectiveRequest struct {
	PrincipalType models.APIPrincipalType `form:"principal_type" binding:"required"`
	PrincipalID   uint                    `form:"principal_id" binding:"required"`
	APIServiceID  uint                    `form:"api_service_id" binding:"required"`
}

type GrantListFinder

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

func NewGrantListFinder

func NewGrantListFinder(db *gorm.DB, query dao.AdminQuery) *GrantListFinder

func (*GrantListFinder) List

func (f *GrantListFinder) List(
	ctx context.Context,
	opts dao.ListOptions,
	filter grantListFilter,
) ([]AccessGrantResponse, int64, error)

type GrantScope

type GrantScope string
const (
	GrantScopeService GrantScope = "service"
	GrantScopeRoutes  GrantScope = "routes"
)

type GrantWriter

type GrantWriter struct{}

GrantWriter owns the internal managed-role representation for quick API access grants.

func (GrantWriter) Delete

func (GrantWriter) Delete(ctx dao.Context, principal PrincipalRef, serviceID uint) error

func (GrantWriter) Replace

func (GrantWriter) Replace(ctx dao.Context, principal PrincipalRef, serviceID uint, scope GrantScope, routeIDs []uint) (ConfiguredGrant, error)

type Handler

type Handler struct {
	App       app.Application
	Publisher apirole.RolePublisher
	Writer    grantWriteOperations
}

func (*Handler) Delete

func (h *Handler) Delete(c *app.Context, req DeleteRequest) (api.StatusResponse, error)

func (*Handler) Effective

func (h *Handler) Effective(c *app.Context, req EffectiveRequest) (AccessGrantResponse, error)

func (*Handler) List

func (*Handler) Replace

func (h *Handler) Replace(c *app.Context, req ReplaceRequest) (ConfiguredGrant, error)

type ListRequest

type ListRequest struct {
	api.PaginationQuery
	PrincipalType *models.APIPrincipalType `form:"principal_type"`
	PrincipalID   *uint                    `form:"principal_id"`
	APIServiceID  *uint                    `form:"api_service_id"`
	Search        string                   `form:"search"`
}

type PrincipalRef

type PrincipalRef struct {
	Type models.APIPrincipalType
	ID   uint
}

type ReplaceGrantRequest

type ReplaceGrantRequest struct {
	Scope    GrantScope `json:"scope" binding:"required"`
	RouteIDs []uint     `json:"route_ids"`
}

type ReplaceRequest

type ReplaceRequest struct {
	PrincipalType models.APIPrincipalType `uri:"principal_type" binding:"required"`
	PrincipalID   uint                    `uri:"principal_id" binding:"required"`
	APIServiceID  uint                    `uri:"service_id" binding:"required"`
	Scope         GrantScope              `json:"scope" binding:"required"`
	RouteIDs      []uint                  `json:"route_ids"`
}

Jump to

Keyboard shortcuts

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