consent

package
v0.0.0-...-e656f7d Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID() string

Types

type Consent struct {
	ID            string                  `bson:"_id"`
	Status        api.ConsentStatus       `bson:"status"`
	UserCPF       string                  `bson:"user_cpf"`
	BusinessCNPJ  string                  `bson:"business_cnpj,omitempty"`
	ClientId      string                  `bson:"client_id"`
	Permissions   []api.ConsentPermission `bson:"permissions"`
	CreatedAt     time.Time               `bson:"created_at"`
	UpdatedAt     time.Time               `bson:"updated_at"`
	ExpiresAt     time.Time               `bson:"expires_at"`
	RejectionInfo *RejectionInfo          `bson:"rejection,omitempty"`
	Data          api.ConsentData         `json:"data"`
}

func (Consent) HasAuthExpired

func (c Consent) HasAuthExpired() bool

HasAuthExpired returns true if the status is [StatusAwaitingAuthorisation] and the max time awaiting authorization has elapsed.

func (Consent) HasPermissions

func (c Consent) HasPermissions(permissions []api.ConsentPermission) bool

func (Consent) IsAuthorized

func (c Consent) IsAuthorized() bool

func (Consent) IsAwaitingAuthorization

func (c Consent) IsAwaitingAuthorization() bool

func (Consent) IsExpired

func (c Consent) IsExpired() bool

IsExpired returns true if the status is [StatusAuthorised] and the consent reached the expiration date.

type EndorsementInfo

type EndorsementInfo struct {
	PolicyNumber string              `bson:"policy_number"`
	Type         api.EndorsementType `bson:"type"`
	Description  string              `bson:"description"`
}

type PermissionCategory

type PermissionCategory []api.ConsentPermission

type RejectionInfo

type RejectionInfo struct {
	RejectedBy api.ConsentRejectedBy         `bson:"rejected_by"`
	Reason     api.ConsentRejectedReasonCode `bson:"reason"`
}

type ServerV2

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

func NewServerV2

func NewServerV2(
	service Service,
) ServerV2

func (ServerV2) ConsentV2

func (ServerV2) CreateConsentV2

func (ServerV2) DeleteConsentV2

type Service

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

func NewService

func NewService(storage Storage, userService user.Service) Service

func (Service) Authorize

func (s Service) Authorize(
	ctx context.Context,
	id string,
	permissions ...api.ConsentPermission,
) error

func (Service) Fetch

func (s Service) Fetch(
	ctx context.Context,
	meta api.RequestMeta,
	id string,
) (
	Consent,
	error,
)

func (Service) FetchAndConsume

func (s Service) FetchAndConsume(
	ctx context.Context,
	meta api.RequestMeta,
	id string,
) (
	Consent,
	error,
)

func (Service) Reject

func (s Service) Reject(
	ctx context.Context,
	meta api.RequestMeta,
	id string,
	info RejectionInfo,
) error

func (Service) Verify

func (s Service) Verify(
	ctx context.Context,
	meta api.RequestMeta,
	id string,
	permissions ...api.ConsentPermission,
) error

Verify checks if the consent with the given ID is authorized and has the required permissions.

type Storage

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

func NewStorage

func NewStorage(db *mongo.Database) Storage

Jump to

Keyboard shortcuts

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