code.gitea.io/gitea@v1.21.7/services/auth/source/sspi/source.go (about)

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