Pkg: Apply "golangci-lint" recommendations to authn & dsn packages #5330

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-21 15:33:23 +01:00
parent 23529d0472
commit 5e4e6d988c
5 changed files with 13 additions and 9 deletions

View File

@@ -81,7 +81,7 @@ var (
ErrInvalidPassword = errors.New("invalid password")
ErrPasswordRequired = errors.New("password required")
ErrPasswordTooShort = errors.New("password is too short")
ErrPasswordTooLong = errors.New(fmt.Sprintf("password must have less than %d characters", txt.ClipPassword))
ErrPasswordTooLong = fmt.Errorf("password must have less than %d characters", txt.ClipPassword)
ErrPasswordsDoNotMatch = errors.New("passwords do not match")
)

View File

@@ -22,9 +22,9 @@ const (
GrantShareToken GrantType = "share_token"
GrantRefreshToken GrantType = "refresh_token"
GrantAuthorizationCode GrantType = "authorization_code"
GrantJwtBearer GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"
GrantSamlBearer GrantType = "urn:ietf:params:oauth:grant-type:saml2-bearer"
GrantTokenExchange GrantType = "urn:ietf:params:oauth:grant-type:token-exchange"
GrantJwtBearer GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer" // #nosec G101 grant type identifier, not a secret
GrantSamlBearer GrantType = "urn:ietf:params:oauth:grant-type:saml2-bearer" // #nosec G101 grant type identifier, not a secret
GrantTokenExchange GrantType = "urn:ietf:params:oauth:grant-type:token-exchange" // #nosec G101 grant type identifier, not a secret
)
// Grant casts a string to a normalized grant type.

View File

@@ -6,6 +6,7 @@ import "github.com/photoprism/photoprism/pkg/clean"
type IssuerUri = string
const (
// IssuerDefault represents the empty issuer URI.
IssuerDefault IssuerUri = ""
)

View File

@@ -10,9 +10,13 @@ import (
)
var (
ErrEmpty = errors.New("empty")
ErrTooLong = errors.New("too long")
ErrInvalid = errors.New("invalid")
// ErrEmpty indicates the username was not provided.
ErrEmpty = errors.New("empty")
// ErrTooLong indicates the username exceeds the allowed length.
ErrTooLong = errors.New("too long")
// ErrInvalid indicates the username failed basic validation.
ErrInvalid = errors.New("invalid")
// ErrReserved indicates the username is reserved for system use.
ErrReserved = errors.New("reserved")
)

View File

@@ -117,8 +117,7 @@ func (d *DSN) Host() string {
// Port the database server port.
func (d *DSN) Port() int {
switch d.Driver {
case DriverSQLite3:
if d.Driver == DriverSQLite3 {
return 0
}