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

123456789101112131415161718192021222324252627282930313233
  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. "code.gitea.io/gitea/models"
  7. "gitea.com/macaron/macaron"
  8. "gitea.com/macaron/session"
  9. )
  10. // SingleSignOn represents a SSO authentication method (plugin) for HTTP requests.
  11. type SingleSignOn interface {
  12. // Init should be called exactly once before using any of the other methods,
  13. // in order to allow the plugin to allocate necessary resources
  14. Init() error
  15. // Free should be called exactly once before application closes, in order to
  16. // give chance to the plugin to free any allocated resources
  17. Free() error
  18. // IsEnabled checks if the current SSO method has been enabled in settings.
  19. IsEnabled() bool
  20. // VerifyAuthData tries to verify the SSO authentication data contained in the request.
  21. // If verification is successful returns either an existing user object (with id > 0)
  22. // or a new user object (with id = 0) populated with the information that was found
  23. // in the authentication data (username or email).
  24. // Returns nil if verification fails.
  25. VerifyAuthData(ctx *macaron.Context, sess session.Store) *models.User
  26. }