cas

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolV2 = "2"
	ProtocolV3 = "3"
)

Variables

View Source
var (
	ErrDisabled             = errors.New("cas login is disabled")
	ErrAuthenticationFailed = errors.New("cas authentication failed")
)

Functions

func SafeRedirect

func SafeRedirect(raw string) string

Types

type Client

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

func NewClient

func NewClient(config Config) (*Client, error)

func NewClientWithHTTPClient

func NewClientWithHTTPClient(config Config, httpClient *http.Client) (*Client, error)

func (*Client) LoginURL

func (c *Client) LoginURL(redirect string) (string, error)

func (*Client) LogoutURL

func (c *Client) LogoutURL(returnURL string) (string, error)

LogoutURL builds the CAS logout address. The caller must clear its local session separately. returnURL must come from trusted application configuration, never unchecked request input.

func (*Client) ServiceURL

func (c *Client) ServiceURL(redirect string) (string, error)

func (*Client) ValidateTicket

func (c *Client) ValidateTicket(ctx context.Context, serviceURL string, ticket string) (Principal, error)

type Config

type Config struct {
	Enabled          bool          `mapstructure:"enabled" yaml:"enabled"`
	ServerURL        string        `mapstructure:"server_url" yaml:"server_url"`
	CallbackURL      string        `mapstructure:"callback_url" yaml:"callback_url"`
	RequestTimeout   time.Duration `mapstructure:"request_timeout" yaml:"request_timeout"`
	Protocol         string        `mapstructure:"protocol" yaml:"protocol"`
	SubjectAttribute string        `mapstructure:"subject_attribute" yaml:"subject_attribute"`
}

func (Config) Normalized

func (c Config) Normalized() Config

func (Config) Validate

func (c Config) Validate() error

type Principal

type Principal struct {
	Subject    string
	Username   string
	Name       string
	Email      string
	Attributes map[string][]string
}

func (Principal) Metadata

func (p Principal) Metadata() map[string]any

Jump to

Keyboard shortcuts

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