You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.go 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package auth
  4. import (
  5. "context"
  6. "net/http"
  7. user_model "code.gitea.io/gitea/models/user"
  8. "code.gitea.io/gitea/modules/session"
  9. "code.gitea.io/gitea/modules/web/middleware"
  10. )
  11. // DataStore represents a data store
  12. type DataStore middleware.ContextDataStore
  13. // SessionStore represents a session store
  14. type SessionStore session.Store
  15. // Method represents an authentication method (plugin) for HTTP requests.
  16. type Method interface {
  17. // Verify tries to verify the authentication data contained in the request.
  18. // If verification is successful returns either an existing user object (with id > 0)
  19. // or a new user object (with id = 0) populated with the information that was found
  20. // in the authentication data (username or email).
  21. // Second argument returns err if verification fails, otherwise
  22. // First return argument returns nil if no matched verification condition
  23. Verify(http *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error)
  24. Name() string
  25. }
  26. // PasswordAuthenticator represents a source of authentication
  27. type PasswordAuthenticator interface {
  28. Authenticate(ctx context.Context, user *user_model.User, login, password string) (*user_model.User, error)
  29. }
  30. // LocalTwoFASkipper represents a source of authentication that can skip local 2fa
  31. type LocalTwoFASkipper interface {
  32. IsSkipLocalTwoFA() bool
  33. }
  34. // SynchronizableSource represents a source that can synchronize users
  35. type SynchronizableSource interface {
  36. Sync(ctx context.Context, updateExisting bool) error
  37. }