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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2021 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 pam
  5. import (
  6. "code.gitea.io/gitea/models/auth"
  7. "code.gitea.io/gitea/modules/json"
  8. )
  9. // __________ _____ _____
  10. // \______ \/ _ \ / \
  11. // | ___/ /_\ \ / \ / \
  12. // | | / | \/ Y \
  13. // |____| \____|__ /\____|__ /
  14. // \/ \/
  15. // Source holds configuration for the PAM login source.
  16. type Source struct {
  17. ServiceName string // pam service (e.g. system-auth)
  18. EmailDomain string
  19. SkipLocalTwoFA bool `json:",omitempty"` // Skip Local 2fa for users authenticated with this source
  20. // reference to the authSource
  21. authSource *auth.Source
  22. }
  23. // FromDB fills up a PAMConfig from serialized format.
  24. func (source *Source) FromDB(bs []byte) error {
  25. return json.UnmarshalHandleDoubleEncode(bs, &source)
  26. }
  27. // ToDB exports a PAMConfig to a serialized format.
  28. func (source *Source) ToDB() ([]byte, error) {
  29. return json.Marshal(source)
  30. }
  31. // SetAuthSource sets the related AuthSource
  32. func (source *Source) SetAuthSource(authSource *auth.Source) {
  33. source.authSource = authSource
  34. }
  35. func init() {
  36. auth.RegisterTypeConfig(auth.PAM, &Source{})
  37. }