1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

auth: godoc: provider, claims provider, transformer, error handler and user helpers

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-04-02 21:14:46 +03:00
parent c5139b22ee
commit dceb09d4ff
3 changed files with 56 additions and 10 deletions

View File

@@ -90,6 +90,19 @@ func New[T User](config Configuration) (*Auth[T], error) {
return s, nil
}
// WithProviderAndErrorHandler registers a provider (if not nil) and
// an error handler (if not nil) and returns this "s" Auth instance.
// It's the same as calling AddProvider and SetErrorHandler at once.
// It's really useful when registering an Auth instance using the iris.Party.PartyConfigure
// method when a Provider of T and ErrorHandler is available through the registered Party's dependencies.
//
// Usage Example:
// api := app.Party("/api")
// api.EnsureStaticBindings().RegisterDependency(
// NewAuthProviderErrorHandler(),
// NewAuthCustomerProvider,
// auth.Must(auth.New[Customer](authConfig)).WithProviderAndErrorHandler,
// )
func (s *Auth[T]) WithProviderAndErrorHandler(provider Provider[T], errHandler ErrorHandler) *Auth[T] {
if provider != nil {
for i := range s.providers {