cas

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValueLength    = 128
	MaxValueLength = 139
	MinValueLength = 32
)

Variables

View Source
var CasErrorCodes = [...]string{
	"INVALID_REQUEST",
	"INVALID_TICKET_SPEC",
	"INVALID_TICKET",
	"INVALID_SERVICE",
	"INVALID_USERNAME",
	"INTERNAL_ERROR",
	"UNAUTHORIZED_SERVICE_PROXY",
	"INVALID_PROXY_CALLBACK",
}

CasErrorCodes contains all error codes in string format

Functions

This section is empty.

Types

type CasError

type CasError struct {
	InnerError error
	Code       CasErrorCode
}

CasError contains CAS error information

func NewCasError

func NewCasError(message string, code CasErrorCode) *CasError

func ValidateService

func ValidateService(service string) *CasError

func ValidateTicket

func ValidateTicket(ticket string) *CasError

func (*CasError) Error

func (c *CasError) Error() string

type CasErrorCode

type CasErrorCode int

CasErrorCode type declaration

const (
	// ERROR_CODE_INVALID_REQUEST "not all of the required request parameters were present"
	ERROR_CODE_INVALID_REQUEST CasErrorCode = 1 + iota
	// ERROR_CODE_INVALID_TICKET_SPEC "failure to meet the requirements of validation specification"
	ERROR_CODE_INVALID_TICKET_SPEC
	// ERROR_CODE_INVALID_TICKET "the ticket provided was not valid, or the ticket did not come from an initial login and renew was set on validation."
	ERROR_CODE_INVALID_TICKET
	// INVALID_SERVICE "the ticket provided was valid, but the service specified did not match the service associated with the ticket."
	ERROR_CODE_INVALID_SERVICE
	// INVALID_USERNAME "the uid (username) was invalid or removed"
	ERROR_CODE_INVALID_USERNAME
	// ERROR_CODE_INTERNAL_ERROR "an internal error occurred during ticket validation"
	ERROR_CODE_INTERNAL_ERROR
	// ERROR_CODE_UNAUTHORIZED_SERVICE_PROXY "the service is not authorized to perform proxy authentication"
	ERROR_CODE_UNAUTHORIZED_SERVICE_PROXY
	// ERROR_CODE_INVALID_PROXY_CALLBACK "The proxy callback specified is invalid. The credentials specified for proxy authentication do not meet the security requirements"
	ERROR_CODE_INVALID_PROXY_CALLBACK
)

func (CasErrorCode) String

func (casErrorCode CasErrorCode) String() string

type MemoryStore added in v0.8.12

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

MemoryStore is memory based Storage

func NewInMemory added in v0.8.12

func NewInMemory() *MemoryStore

NewMemoryStore returns new instance of MemoryStore

func (*MemoryStore) DeleteTicket added in v0.8.12

func (s *MemoryStore) DeleteTicket(ticket string)

DeleteTicket deletes given ticket

func (*MemoryStore) GetTicket added in v0.8.12

func (s *MemoryStore) GetTicket(ticket string) *Ticket

DoesTicketExist checks if given ticket exists

func (*MemoryStore) SaveTicket added in v0.8.12

func (s *MemoryStore) SaveTicket(ticket *Ticket)

SaveTicket stores the Ticket

type Ticket

type Ticket struct {
	Id        int       `db:"id,pk" json:"id" form:"id"` // seriel in database
	Class     string    `db:"type" json:"type"`          // ticket type: ST, PGT, PT, ...
	Value     string    `db:"value" json:"value"`        // ticket id: (ST-|PGT-|PT-)
	UID       string    `db:"uid" json:"uid"`            // uid in staff
	Service   string    `db:"service" json:"service"`    // is an URL
	CreatedAt time.Time `db:"created" json:"created"`
	Renew     bool
}

func NewTicket

func NewTicket(class string, service string, uid string, renew bool) *Ticket

func (*Ticket) Check

func (t *Ticket) Check() *CasError

func (*Ticket) IsOld

func (t *Ticket) IsOld() bool

type TicketStore added in v0.6.3

type TicketStore interface {
	GetTicket(value string) (*Ticket, error)
	DeleteTicket(value string) error
	SaveTicket(t *Ticket) error
}

Jump to

Keyboard shortcuts

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