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

     1  // Copyright 2021 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package db
     5  
     6  import (
     7  	"context"
     8  
     9  	"code.gitea.io/gitea/models/auth"
    10  	user_model "code.gitea.io/gitea/models/user"
    11  )
    12  
    13  // Source is a password authentication service
    14  type Source struct{}
    15  
    16  // FromDB fills up an OAuth2Config from serialized format.
    17  func (source *Source) FromDB(bs []byte) error {
    18  	return nil
    19  }
    20  
    21  // ToDB exports an SMTPConfig to a serialized format.
    22  func (source *Source) ToDB() ([]byte, error) {
    23  	return nil, nil
    24  }
    25  
    26  // Authenticate queries if login/password is valid against the PAM,
    27  // and create a local user if success when enabled.
    28  func (source *Source) Authenticate(ctx context.Context, user *user_model.User, login, password string) (*user_model.User, error) {
    29  	return Authenticate(ctx, user, login, password)
    30  }
    31  
    32  func init() {
    33  	auth.RegisterTypeConfig(auth.NoType, &Source{})
    34  	auth.RegisterTypeConfig(auth.Plain, &Source{})
    35  }