gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package sspi
  4. import (
  5. "code.gitea.io/gitea/models/auth"
  6. "code.gitea.io/gitea/modules/json"
  7. )
  8. // _________ ___________________.___
  9. // / _____// _____/\______ \ |
  10. // \_____ \ \_____ \ | ___/ |
  11. // / \/ \ | | | |
  12. // /_______ /_______ / |____| |___|
  13. // \/ \/
  14. // Source holds configuration for SSPI single sign-on.
  15. type Source struct {
  16. auth.ConfigBase `json:"-"`
  17. AutoCreateUsers bool
  18. AutoActivateUsers bool
  19. StripDomainNames bool
  20. SeparatorReplacement string
  21. DefaultLanguage string
  22. }
  23. // FromDB fills up an SSPIConfig from serialized format.
  24. func (cfg *Source) FromDB(bs []byte) error {
  25. return json.UnmarshalHandleDoubleEncode(bs, &cfg)
  26. }
  27. // ToDB exports an SSPIConfig to a serialized format.
  28. func (cfg *Source) ToDB() ([]byte, error) {
  29. return json.Marshal(cfg)
  30. }
  31. func init() {
  32. auth.RegisterTypeConfig(auth.SSPI, &Source{})
  33. }