Fix golint errors

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-02-02 15:24:11 +01:00
parent b11ce54ccc
commit ece54f1616
38 changed files with 134 additions and 204 deletions

View File

@@ -499,7 +499,7 @@ func (s AuthService) OpenSessionWithPassword(ctx context.Context, email mail.Add
// Perform a password comparison even when the identity does not exist to mitigate timing attacks
// and prevent revealing account existence.
if identity.ID == gid.Nil {
s.hp.ComparePasswordAndHash([]byte(password+"qwertyuiop1234567890"), []byte("qwertyuiop1234567890"))
_, _ = s.hp.ComparePasswordAndHash([]byte(password+"qwertyuiop1234567890"), []byte("qwertyuiop1234567890"))
return NewInvalidCredentialsError("invalid email or password")
}

View File

@@ -111,44 +111,6 @@ func extractAttributeValue(assertion *saml.Assertion, attributeName string) (str
return "", fmt.Errorf("attribute %q not found in assertion", attributeName)
}
func extractEmailFromAssertion(assertion *saml.Assertion) (string, error) {
commonEmailAttributes := []string{
"email",
"Email",
"emailAddress",
"mail",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
"http://schemas.xmlsoap.org/claims/EmailAddress",
}
for _, attrName := range commonEmailAttributes {
email, err := extractAttributeValue(assertion, attrName)
if err == nil && email != "" {
return email, nil
}
}
if assertion.Subject != nil && assertion.Subject.NameID != nil && assertion.Subject.NameID.Value != "" {
return assertion.Subject.NameID.Value, nil
}
return "", fmt.Errorf("could not extract email from assertion")
}
func extractEmailDomain(email string) (string, error) {
parts := strings.Split(email, "@")
if len(parts) != 2 {
return "", fmt.Errorf("invalid email address: %s", email)
}
domain := strings.ToLower(strings.TrimSpace(parts[1]))
if domain == "" {
return "", fmt.Errorf("empty domain in email address: %s", email)
}
return domain, nil
}
func mapSAMLRoleToSystemRole(samlRole string) *coredata.MembershipRole {
if samlRole != "" && isValidRole(samlRole) {
role := coredata.MembershipRole(samlRole)

View File

@@ -97,7 +97,7 @@ func (c *Client) listUsersPage(ctx context.Context, startIndex, count int) (User
if err != nil {
return nil, 0, fmt.Errorf("cannot fetch users: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
@@ -150,7 +150,7 @@ func (c *Client) CreateUser(ctx context.Context, user *User) error {
if err != nil {
return fmt.Errorf("cannot create user: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
respBody, _ := io.ReadAll(resp.Body)
@@ -198,7 +198,7 @@ func (c *Client) UpdateUser(ctx context.Context, userID string, user *User) erro
if err != nil {
return fmt.Errorf("cannot update user: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
respBody, _ := io.ReadAll(resp.Body)
@@ -238,7 +238,7 @@ func (c *Client) DeactivateUser(ctx context.Context, userID string) error {
if err != nil {
return fmt.Errorf("cannot deactivate user: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
respBody, _ := io.ReadAll(resp.Body)