code.gitea.io/gitea@v1.22.3/services/auth/interface.go (about) 1 // Copyright 2019 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package auth 5 6 import ( 7 "context" 8 "net/http" 9 10 user_model "code.gitea.io/gitea/models/user" 11 "code.gitea.io/gitea/modules/session" 12 "code.gitea.io/gitea/modules/web/middleware" 13 ) 14 15 // DataStore represents a data store 16 type DataStore middleware.ContextDataStore 17 18 // SessionStore represents a session store 19 type SessionStore session.Store 20 21 // Method represents an authentication method (plugin) for HTTP requests. 22 type Method interface { 23 // Verify tries to verify the authentication data contained in the request. 24 // If verification is successful returns either an existing user object (with id > 0) 25 // or a new user object (with id = 0) populated with the information that was found 26 // in the authentication data (username or email). 27 // Second argument returns err if verification fails, otherwise 28 // First return argument returns nil if no matched verification condition 29 Verify(http *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) 30 31 Name() string 32 } 33 34 // PasswordAuthenticator represents a source of authentication 35 type PasswordAuthenticator interface { 36 Authenticate(ctx context.Context, user *user_model.User, login, password string) (*user_model.User, error) 37 } 38 39 // LocalTwoFASkipper represents a source of authentication that can skip local 2fa 40 type LocalTwoFASkipper interface { 41 IsSkipLocalTwoFA() bool 42 } 43 44 // SynchronizableSource represents a source that can synchronize users 45 type SynchronizableSource interface { 46 Sync(ctx context.Context, updateExisting bool) error 47 }