Documentation
¶
Index ¶
- Variables
- func GetLog(r *http.Request) logrus.FieldLogger
- func SaveTransaction(w http.ResponseWriter, r *http.Request, t *Transaction) error
- func WithError(r *http.Request, err error) *http.Request
- func WithField(r *http.Request, key string, value any) *http.Request
- func WithFields(r *http.Request, fields logrus.Fields) *http.Request
- func WithLog(r *http.Request, l logrus.FieldLogger) *http.Request
- func WithProvider(r *http.Request, p Provider) *http.Request
- type Provider
- type ProviderConfig
- type ProviderRegistry
- type Server
- type StaticProviderRegistry
- type TokenizerConfig
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ErrProviderNotFound = errors.New("provider not found")
Functions ¶
func GetLog ¶
func GetLog(r *http.Request) logrus.FieldLogger
Gets the logrus.FieldLogger from the context. Requests are logged by Transaction.ReturnData/ReturnError.
func SaveTransaction ¶
func SaveTransaction(w http.ResponseWriter, r *http.Request, t *Transaction) error
SaveTransaction updates an existing transaction cookie.
func WithError ¶
Updates the logrus.FieldLogger in the context with "error" field. Requests are logged by Transaction.ReturnData/ReturnError.
func WithField ¶
Updates the logrus.FieldLogger in the context with added field. Requests are logged by Transaction.ReturnData/ReturnError.
func WithFields ¶
Updates the logrus.FieldLogger in the context with added fields. Requests are logged by Transaction.ReturnData/ReturnError.
Types ¶
type Provider ¶
type Provider interface {
http.Handler
Validate() error
PC() *ProviderConfig
}
func GetProvider ¶
type ProviderConfig ¶
type ProviderConfig struct {
Tokenizer TokenizerConfig
// URL is the full URL where this provider is served from.
URL url.URL
// ReturnURL is the URL that the provider should redirect to after
// authenticating the user.
ReturnURL url.URL
}
func (*ProviderConfig) Validate ¶
func (p *ProviderConfig) Validate() error
type ProviderRegistry ¶
type Server ¶
type Server struct {
// Address is populated with the listening address after [Start] is called.
Address string
// Done is closed when the server has stopped. It is not populated until
// [Start] is called.
Done chan struct{}
// Err is populated with any error returned by the HTTP server. It should
// not be read until Done is closed.
Err error
// contains filtered or unexported fields
}
type StaticProviderRegistry ¶
type TokenizerConfig ¶
type TokenizerConfig struct {
// SealKey is the key we encrypt tokens to.
SealKey string
// Auth specifies the auth requires to use the sealed token.
Auth tokenizer.AuthConfig
// RequestValidators specifies validations that tokenizer should run on
// requests before unsealing/adding token. Eg. limit what hosts the token
// can be sent to.
RequestValidators []tokenizer.RequestValidator
}
func (*TokenizerConfig) SealedSecret ¶
func (t *TokenizerConfig) SealedSecret(processor tokenizer.ProcessorConfig) (string, error)
func (*TokenizerConfig) Validate ¶
func (t *TokenizerConfig) Validate() error
type Transaction ¶
type Transaction struct {
// Random state string that will be returned in our redirect to the relying
// party. This is used to prevent login-CSRF attacks.
ReturnState string
// Random string that provider implementations can use as the state
// parameter for downstream SSO flows.
Nonce string
// Time after which this transaction cookie will be ignored.
Expiry time.Time
// Parameters forwarded from the start request that should also be sent
// to the token exchange request (e.g., source_id for Vanta).
ForwardedParams map[string]string
}
State about the user's SSO attempt that is stored as a cookie. Cookies are set with per-provider paths to prevent transactions from different providers from interfering with each other.
func RestoreTransaction ¶
func RestoreTransaction(w http.ResponseWriter, r *http.Request) *Transaction
func StartTransaction ¶
func StartTransaction(w http.ResponseWriter, r *http.Request) *Transaction
func (*Transaction) ReturnData ¶
func (t *Transaction) ReturnData(w http.ResponseWriter, r *http.Request, data map[string]string)
Return the user to the returnURL with the provided data set as query string parameters.
func (*Transaction) ReturnError ¶
func (t *Transaction) ReturnError(w http.ResponseWriter, r *http.Request, msg string)
Return the user to the returnURL with the provided msg set in the `error` query string parameter.