kataras/iris · error

auth: signin: no provider

Error message

auth: signin: no provider

What it means

Auth.Signin returns 'auth: signin: no provider' when the Auth instance has no providers registered, so there is nothing to attempt authentication against. This is a configuration error, not a credential failure — the loop over s.providers never runs and the else branch fires. It signals the Auth service was constructed without any Signin providers attached.

Solutions

  1. Register at least one provider (e.g. a database-backed provider) before serving auth routes
  2. Check that provider-registration code actually runs (no early return / env guard skipping it)
  3. Add a startup assertion that len(providers) > 0 to fail fast at boot

Example fix

// before
auth := iris.NewAuth(jwtSigner) // no providers
// after
auth := iris.NewAuth(jwtSigner)
auth.AddProvider(dbProvider)
Defensive patterns

Strategy: validation

Validate before calling

// fail fast at boot
if len(a.Providers()) == 0 {
    log.Fatal("auth: no signin providers registered")
}

Type guard

func isNoProviderErr(err error) bool { return err != nil && strings.Contains(err.Error(), "auth: signin: no provider") }

Try / catch

if _, _, err := a.Signin(ctx, user, pass); err != nil {
    if strings.Contains(err.Error(), "no provider") {
        return http.StatusServiceUnavailable // server misconfig, not user error
    }
    return http.StatusUnauthorized
}

Prevention

When it happens

Trigger: Calling Signin/SigninHandler on an Auth[T] built without AddProvider (or equivalent registration) — s.providers is empty so the for-loop is skipped and the else branch errors.

Common situations: Forgetting to register any auth provider during wiring; conditional registration code that never executes (e.g. env-based setup skipped); constructing Auth in tests without providers.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/4ea25075c278d08d. Report an issue: GitHub.

Appendix: source

Thrown at auth/auth.go:245

	if n := len(s.providers); n > 0 {
		for i := 0; i < n; i++ {
			p := s.providers[i]

			v, err := p.Signin(ctx, username, password)
			if err != nil {
				if i == n-1 { // last provider errored.
					return nil, nil, fmt.Errorf("auth: signin: %w", err)
				}
				// keep searching.
				continue
			}

			// found.
			t = v
			break
		}
	} else {
		return nil, nil, fmt.Errorf("auth: signin: no provider")
	}

	// sign the tokens.
	accessToken, refreshToken, err := s.sign(t)
	if err != nil {
		return nil, nil, fmt.Errorf("auth: signin: %w", err)
	}

	return accessToken, refreshToken, nil
}

func (s *Auth[T]) sign(t T) ([]byte, []byte, error) {
	// sign the tokens.
	var (
		accessStdClaims  StandardClaims
		refreshStdClaims StandardClaims
	)

View on GitHub (pinned to 7bedaf55a0)