From 5e4e6d988ced254ca42af0d591b1e3494e9e1039 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 21 Nov 2025 15:33:23 +0100 Subject: [PATCH] Pkg: Apply "golangci-lint" recommendations to authn & dsn packages #5330 Signed-off-by: Michael Mayer --- pkg/authn/errors.go | 2 +- pkg/authn/grants.go | 6 +++--- pkg/authn/issuer.go | 1 + pkg/authn/username.go | 10 +++++++--- pkg/dsn/dsn.go | 3 +-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/authn/errors.go b/pkg/authn/errors.go index 4a97279a3..0b86f5ac1 100644 --- a/pkg/authn/errors.go +++ b/pkg/authn/errors.go @@ -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") ) diff --git a/pkg/authn/grants.go b/pkg/authn/grants.go index 9801bbee4..8093a3a38 100644 --- a/pkg/authn/grants.go +++ b/pkg/authn/grants.go @@ -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. diff --git a/pkg/authn/issuer.go b/pkg/authn/issuer.go index 34e85bd4d..6ab3a6298 100644 --- a/pkg/authn/issuer.go +++ b/pkg/authn/issuer.go @@ -6,6 +6,7 @@ import "github.com/photoprism/photoprism/pkg/clean" type IssuerUri = string const ( + // IssuerDefault represents the empty issuer URI. IssuerDefault IssuerUri = "" ) diff --git a/pkg/authn/username.go b/pkg/authn/username.go index ac340e63a..b4a2ae961 100644 --- a/pkg/authn/username.go +++ b/pkg/authn/username.go @@ -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") ) diff --git a/pkg/dsn/dsn.go b/pkg/dsn/dsn.go index 1a2731d30..fe4aa9271 100644 --- a/pkg/dsn/dsn.go +++ b/pkg/dsn/dsn.go @@ -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 }