gitea源码

source.go 927B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package pam
  4. import (
  5. "code.gitea.io/gitea/models/auth"
  6. "code.gitea.io/gitea/modules/json"
  7. )
  8. // __________ _____ _____
  9. // \______ \/ _ \ / \
  10. // | ___/ /_\ \ / \ / \
  11. // | | / | \/ Y \
  12. // |____| \____|__ /\____|__ /
  13. // \/ \/
  14. // Source holds configuration for the PAM login source.
  15. type Source struct {
  16. auth.ConfigBase `json:"-"`
  17. ServiceName string // pam service (e.g. system-auth)
  18. EmailDomain string
  19. }
  20. // FromDB fills up a PAMConfig from serialized format.
  21. func (source *Source) FromDB(bs []byte) error {
  22. return json.UnmarshalHandleDoubleEncode(bs, &source)
  23. }
  24. // ToDB exports a PAMConfig to a serialized format.
  25. func (source *Source) ToDB() ([]byte, error) {
  26. return json.Marshal(source)
  27. }
  28. func init() {
  29. auth.RegisterTypeConfig(auth.PAM, &Source{})
  30. }