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