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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package sso
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/models"
  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.DataStore
  13. // SessionStore represents a session store
  14. type SessionStore session.Store
  15. // SingleSignOn represents a SSO authentication method (plugin) for HTTP requests.
  16. type SingleSignOn interface {
  17. // Init should be called exactly once before using any of the other methods,
  18. // in order to allow the plugin to allocate necessary resources
  19. Init() error
  20. // Free should be called exactly once before application closes, in order to
  21. // give chance to the plugin to free any allocated resources
  22. Free() error
  23. // IsEnabled checks if the current SSO method has been enabled in settings.
  24. IsEnabled() bool
  25. // VerifyAuthData tries to verify the SSO authentication data contained in the request.
  26. // If verification is successful returns either an existing user object (with id > 0)
  27. // or a new user object (with id = 0) populated with the information that was found
  28. // in the authentication data (username or email).
  29. // Returns nil if verification fails.
  30. VerifyAuthData(http *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User
  31. }