Documentation
¶
Index ¶
- func GetLog(r *http.Request) logrus.FieldLogger
- 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
- type ProviderConfig
- type Server
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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 ProviderConfig ¶
type ProviderConfig interface { // Register should validate the provider configuration and return a handler // for requests to the provider. The provider can call GetTransaction to // receive user state from the in-progress SSO transaction. The Transaction // can be used to return data or error messages to the relying party. Register(sealKey string, auth tokenizer.AuthConfig) (http.Handler, error) }
Arbitrary configuration type for providers to implement.
type Server ¶
type Server struct { Address string Done chan struct{} Err error // contains filtered or unexported fields }
func NewServer ¶
Returns a new Server. When a user successfully completes SSO, the sealKey is used to encrypt the resulting token for use with tokenizer. The rpAuth is set as the authentication token for the tokenizer sealed token and must be provided to tokenizer by the relying party in order to use the sealed token.
func (*Server) AddProvider ¶
func (s *Server) AddProvider(name string, pc ProviderConfig, returnURL string, auth tokenizer.AuthConfig) error
Configure the server with an SSO provider. The name dictates the path that the provider's routes are served under. The returnURL is where the user is returned after an SSO transaction completes.
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 }
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.