You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Corrected grammar and clarified comments within the `AuthState` struct and associated methods in the `auth.go` file. Added initialization of `accountName` variable for feature handling to ensure proper flow and readability.
Signed-off-by: Christian Roessner <[email protected]>
Copy file name to clipboardExpand all lines: server/core/auth.go
+32-21
Original file line number
Diff line number
Diff line change
@@ -130,30 +130,30 @@ type JSONRequest struct {
130
130
AuthLoginAttemptuint`json:"auth_login_attempt"`
131
131
}
132
132
133
-
// AuthState represents a struct that holds information related to authentication process.
133
+
// AuthState represents a struct that holds information related to an authentication process.
134
134
typeAuthStatestruct {
135
135
// StartTime represents the starting time of a client request.
136
136
StartTime time.Time
137
137
138
-
// HaveAccountField is a flag that is set, if a user account field was found in a Database.
138
+
// HaveAccountField is a flag that is set if a user account field was found in a Database.
139
139
HaveAccountFieldbool
140
140
141
-
// NoAuth is a flag that is set, if the request mode does not require authentication.
141
+
// NoAuth is a flag that is set if the request mode does not require authentication.
142
142
NoAuthbool
143
143
144
-
// ListAccounts is a flag that is set, if Nauthilus is requested to send a full list of available user accounts.
144
+
// ListAccounts is a flag that is set if Nauthilus is requested to send a full list of available user accounts.
145
145
ListAccountsbool
146
146
147
-
// UserFound is a flag that is set, if a password Database found the user.
147
+
// UserFound is a flag that is set if a password Database found the user.
148
148
UserFoundbool
149
149
150
-
// PasswordsAccountSeen is a counter that is increased whenever a new failed password was detected for the current account.
150
+
// PasswordsAccountSeen is a counter increased whenever a new failed password was detected for the current account.
151
151
PasswordsAccountSeenuint
152
152
153
-
// PasswordsTotalSeen is a counter that is increased whenever a new failed password was detected.
153
+
// PasswordsTotalSeen is a counter increased whenever a new failed password was detected.
154
154
PasswordsTotalSeenuint
155
155
156
-
// LoginAttempts is a counter that is incremented for each failed login request
156
+
// LoginAttempts is a counter incremented for each failed login request
157
157
LoginAttemptsuint
158
158
159
159
// StatusCodeOk is the HTTP status code that is set by setStatusCodes.
@@ -165,21 +165,21 @@ type AuthState struct {
165
165
// StatusCodeFail is the HTTP status code that is set by setStatusCodes.
166
166
StatusCodeFailint
167
167
168
-
// GUID is a global unique identifier that is inherited in all functions and methods that deal with the
169
-
// authentication process. It is needed to track log lines belonging to one request.
168
+
// GUID is a global unique identifier inherited in all functions and methods that deal with the
169
+
// authentication process. It is necessary to track log lines belonging to one request.
170
170
GUID*string
171
171
172
172
// Method is set by the "Auth-Method" HTTP request header (Nginx protocol). It is typically something like "plain"
173
173
// or "login".
174
174
Method*string
175
175
176
-
// AccountField is the name of either a SQL field name or an LDAP attribute that was used to retrieve a user account.
176
+
// AccountField is the name of either an SQL field name or an LDAP attribute that was used to retrieve a user account.
177
177
AccountField*string
178
178
179
-
// Username is the value that was taken from the HTTP header "Auth-User" (Nginx protocol).
179
+
// Username is the value taken from the HTTP header "Auth-User" (Nginx protocol).
180
180
Usernamestring
181
181
182
-
// Password is the value that was taken from the HTTP header "Auth-Pass" (Nginx protocol).
182
+
// Password is the value taken from the HTTP header "Auth-Pass" (Nginx protocol).
183
183
Passwordstring
184
184
185
185
// ClientIP is the IP of a client that is to be authenticated. The value is set by the HTTP request header
@@ -243,7 +243,7 @@ type AuthState struct {
243
243
// FeatureName is the name of a feature that has triggered a reject.
244
244
FeatureNamestring
245
245
246
-
// TOTPSecret is used to store a TOTP secret in a SQL Database.
246
+
// TOTPSecret is used to store a TOTP secret in an SQL Database.
247
247
TOTPSecret*string
248
248
249
249
// TOTPSecretField is the SQL field or LDAP attribute that resolves the TOTP secret for two-factor authentication.
@@ -267,7 +267,7 @@ type AuthState struct {
267
267
BruteForceCountermap[string]uint
268
268
269
269
// SourcePassDBBackend is a marker for the Database that is responsible for a specific user. It is set by the
270
-
// password Database and stored in Redis to track the authentication flow accross databases (including proxy).
270
+
// password Database and stored in Redis to track the authentication flow across databases (including proxy).
271
271
SourcePassDBBackend global.Backend
272
272
273
273
// UsedPassDBBackend is set by the password Database that answered the current authentication request.
@@ -280,7 +280,7 @@ type AuthState struct {
280
280
UsedBackendPortint
281
281
282
282
// Attributes is a result container for SQL and LDAP queries. Databases store their result by using a field or
283
-
// attribute name as key and the corresponding result as value.
283
+
// attribute name as a key and the corresponding result as a value.
284
284
Attributes backend.DatabaseResult
285
285
286
286
// Protocol is set by the HTTP request header "Auth-Protocol" (Nginx protocol).
@@ -322,7 +322,7 @@ type PassDBResult struct {
322
322
// DisplayNameField is the display name of a user
323
323
DisplayNameField*string
324
324
325
-
// Backend is set by the Database backend which has found the user.
325
+
// Backend is set by the Database backend, which has found the user.
326
326
Backend global.Backend
327
327
328
328
// Attributes is the result catalog returned by the underlying password Database.
@@ -336,7 +336,7 @@ type (
336
336
337
337
// PassDBMap is a struct type that represents a mapping between a backend type and a PassDBOption function.
338
338
// It is used in the verifyPassword method of the AuthState struct to perform password verification against multiple databases.
339
-
// The backend field represents the type of database backend (global.Backend) and the fn field represents the PassDBOption function.
339
+
// The backend field represents the type of database backend (global.Backend), and the fn field represents the PassDBOption function.
340
340
// The PassDBOption function takes an AuthState pointer as input and returns a PassDBResult pointer and an error.
341
341
// The PassDBResult pointer contains the result of the password verification process.
342
342
// This struct is used to store the database mappings in an array and loop through them in the verifyPassword method.
@@ -586,7 +586,8 @@ func (a *AuthState) authOK(ctx *gin.Context) {
586
586
587
587
// setCommonHeaders sets common headers for the given gin.Context and AuthState.
588
588
// It sets the "Auth-Status" header to "OK" and the "X-Nauthilus-Session" header to the GUID of the AuthState.
589
-
// If the AuthState's Service is not global.ServBasicAuth and the HaveAccountField flag is true, it retrieves the account from the AuthState and sets the "Auth-User" header
589
+
// If the AuthState's Service is not global.ServBasicAuth, and the HaveAccountField flag is true,
590
+
// it retrieves the account from the AuthState and sets the "Auth-User" header
@@ -691,7 +692,7 @@ func handleAttributeValue(ctx *gin.Context, name string, value []any) {
691
692
692
693
// formatValues takes an array of values and formats them into strings.
693
694
// It creates an empty slice of strings called stringValues.
694
-
// It then iterates over each value in the values array and appends the formatted string representation of that value to stringValues using fmt.Sprintf("%v", values[index]).
695
+
// It then iterates over each value in the "values" array and appends the formatted string representation of that value to stringValues using fmt.Sprintf("%v", values[index]).
695
696
// After iterating over all the values, it returns stringValues.
0 commit comments