Documentation
¶
Overview ¶
Package failure classifies a failed action for the Outcome a provider reports, and answers and reports a provider's requests. Its functions and the Reporter are safe for concurrent use.
Index ¶
- func Result(err error) auth.Result
- func UnlessAbsent(err error) error
- type Reporter
- func (r *Reporter) Refuse(ctx context.Context, writer http.ResponseWriter, outcome auth.Outcome)
- func (r *Reporter) RefuseCallback(ctx context.Context, writer http.ResponseWriter, outcome auth.Outcome)
- func (r *Reporter) Report(ctx context.Context, outcome auth.Outcome)
- func (r *Reporter) ReportFailure(ctx context.Context, outcome auth.Outcome)
- type ReporterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Result ¶
Result is the Result of an action that failed with err (not nil): auth.ResultError when auth.ResponseFor answers err with 500, auth.ResultDenied (a refusal) otherwise.
func UnlessAbsent ¶
UnlessAbsent returns err unless it only says that there is nothing (auth.ErrUnauthenticated), e.g. no session or no identity in it.
Types ¶
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter answers a provider's failed requests and reports the outcome of every request.
func NewReporter ¶
func NewReporter(options *ReporterOptions) (*Reporter, error)
NewReporter validates options and returns a Reporter working on a copy of them.
func (*Reporter) RefuseCallback ¶
func (r *Reporter) RefuseCallback(ctx context.Context, writer http.ResponseWriter, outcome auth.Outcome)
RefuseCallback is Refuse, except that with ErrorURL set the failure (a refusal or code=internal) redirects to ErrorURL?code=<code>.
type ReporterOptions ¶
type ReporterOptions struct {
Provider string // required; set as Outcome.Provider
Observer auth.Observer // optional; nil reports nothing
ErrorURL string // optional; where RefuseCallback sends the browser: a path or an absolute http(s) URL, without a fragment
}
ReporterOptions configures NewReporter.