grant

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 146

Documentation

Index

Constants

View Source
const (
	GrantCancelledErrorReason = "grant_cancelled"
	GrantCancelledErrorDomain = "github.com/conductorone/baton-sdk"
)
View Source
const UnknownGrantId string = "🧸_UNKNOWN_GRANT_ID"

Sometimes C1 doesn't have the grant ID, but does have the principal and entitlement.

Variables

This section is empty.

Functions

func AppendGrantReplaced added in v0.9.12

func AppendGrantReplaced(annos annotations.Annotations, replacedGrantID string) annotations.Annotations

AppendGrantReplaced appends a GrantReplaced annotation to the given annotations slice and returns the updated slice. Convenience wrapper around NewGrantReplaced for the common case where the caller is building a response annotations slice inline.

func GrantCancelledReasonFromStatus added in v0.12.3

func GrantCancelledReasonFromStatus(st *status.Status) (string, bool)

GrantCancelledReasonFromStatus returns the connector-supplied reason if status carries the grant-cancelled ErrorInfo detail.

func IsErrGrantCancelled added in v0.12.3

func IsErrGrantCancelled(err error) (string, bool)

IsErrGrantCancelled reports whether err is an intentionally declined grant, returning the connector-supplied reason. It matches both the typed error (in-process) and the flattened gRPC status detail (across a transport).

func NewErrGrantCancelled added in v0.10.0

func NewErrGrantCancelled(reason string) error

func NewGrant

func NewGrant(resource *v2.Resource, entitlementName string, principal GrantPrincipal, grantOptions ...GrantOption) *v2.Grant

NewGrant returns a new grant for the given entitlement on the resource for the provided principal resource ID.

func NewGrantID added in v0.2.84

func NewGrantID(principal GrantPrincipal, entitlement *v2.Entitlement) string

func NewGrantReplaced added in v0.9.12

func NewGrantReplaced(replacedGrantID string) *v2.GrantReplaced

NewGrantReplaced returns a GrantReplaced annotation suitable for appending to the annotations slice returned from a Grant provisioning call.

replacedGrantID is the ID of the grant that the new grant atomically replaced. ConductorOne marks it revoked without dispatching a separate Revoke RPC.

Typical use:

annos := annotations.Annotations{}
annos.Append(grant.NewGrantReplaced(currentGrant.GetId()))
return newGrants, annos, nil

Types

type ErrGrantCancelled added in v0.10.0

type ErrGrantCancelled struct {
	Reason string
}

ErrGrantCancelled indicates a connector intentionally declined to create a grant.

func (*ErrGrantCancelled) Error added in v0.10.0

func (e *ErrGrantCancelled) Error() string

func (*ErrGrantCancelled) GRPCStatus added in v0.12.3

func (e *ErrGrantCancelled) GRPCStatus() *status.Status

GRPCStatus encodes the cancellation as a FailedPrecondition status carrying a typed ErrorInfo detail. The status flattening that the connector gRPC boundary applies to handler errors otherwise discards the Go error type; the detail rides the wire so C1 can recognize an intentional decline rather than treating it as a connector failure.

type GrantOption

type GrantOption func(*v2.Grant) error

func WithAnnotation

func WithAnnotation(msgs ...proto.Message) GrantOption

func WithExternalPrincipalID added in v0.1.15

func WithExternalPrincipalID(externalID *v2.ExternalId) GrantOption

WithExternalPrincipalID: Deprecated. This field is no longer used.

func WithGrantMetadata added in v0.1.1

func WithGrantMetadata(metadata map[string]interface{}) GrantOption

type GrantPrincipal added in v0.0.20

type GrantPrincipal interface {
	proto.Message
	GetBatonResource() bool
}

Jump to

Keyboard shortcuts

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