mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-14 06:51:15 +00:00
chore: replace logrus with standard lib log/slog
This commit is contained in:
@@ -7,13 +7,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/sirupsen/logrus"
|
||||
evbus "github.com/vardius/message-bus"
|
||||
|
||||
"github.com/h44z/wg-portal/internal/app"
|
||||
@@ -227,7 +227,7 @@ func (a *Authenticator) passwordAuthentication(
|
||||
rawUserInfo, err := ldapAuth.GetUserInfo(context.Background(), identifier)
|
||||
if err != nil {
|
||||
if !errors.Is(err, domain.ErrNotFound) {
|
||||
logrus.Warnf("failed to fetch ldap user info for %s: %v", identifier, err)
|
||||
slog.Warn("failed to fetch ldap user info", "identifier", identifier, "error", err)
|
||||
}
|
||||
continue // user not found / other ldap error
|
||||
}
|
||||
@@ -407,8 +407,10 @@ func (a *Authenticator) registerNewUser(
|
||||
return nil, fmt.Errorf("failed to register new user: %w", err)
|
||||
}
|
||||
|
||||
logrus.Tracef("registered user %s from external authentication provider, admin user: %t",
|
||||
user.Identifier, user.IsAdmin)
|
||||
slog.Debug("registered user from external authentication provider",
|
||||
"user", user.Identifier,
|
||||
"isAdmin", user.IsAdmin,
|
||||
"provider", source)
|
||||
|
||||
return user, nil
|
||||
}
|
||||
@@ -483,8 +485,10 @@ func (a *Authenticator) updateExternalUser(
|
||||
return fmt.Errorf("failed to update user: %w", err)
|
||||
}
|
||||
|
||||
logrus.Tracef("updated user %s with data from external authentication provider, admin user: %t",
|
||||
existingUser.Identifier, existingUser.IsAdmin)
|
||||
slog.Debug("updated user with data from external authentication provider",
|
||||
"user", existingUser.Identifier,
|
||||
"isAdmin", existingUser.IsAdmin,
|
||||
"provider", source)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/h44z/wg-portal/internal"
|
||||
"github.com/h44z/wg-portal/internal/config"
|
||||
@@ -117,7 +117,10 @@ func (l LdapAuthenticator) GetUserInfo(_ context.Context, userId domain.UserIden
|
||||
|
||||
if l.cfg.LogUserInfo {
|
||||
contents, _ := json.Marshal(users[0])
|
||||
logrus.Tracef("User info from LDAP source %s for %s: %v", l.GetName(), userId, string(contents))
|
||||
slog.Debug("LDAP user info",
|
||||
"source", l.GetName(),
|
||||
"userId", userId,
|
||||
"info", string(contents))
|
||||
}
|
||||
|
||||
return users[0], nil
|
||||
|
@@ -5,10 +5,10 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/h44z/wg-portal/internal"
|
||||
@@ -111,7 +111,9 @@ func (p PlainOauthAuthenticator) GetUserInfo(
|
||||
}
|
||||
|
||||
if p.userInfoLogging {
|
||||
logrus.Tracef("User info from OAuth source %s: %v", p.name, string(contents))
|
||||
slog.Debug("OAuth user info",
|
||||
"source", p.name,
|
||||
"info", string(contents))
|
||||
}
|
||||
|
||||
return userFields, nil
|
||||
|
@@ -5,9 +5,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/h44z/wg-portal/internal/config"
|
||||
@@ -106,7 +106,9 @@ func (o OidcAuthenticator) GetUserInfo(ctx context.Context, token *oauth2.Token,
|
||||
|
||||
if o.userInfoLogging {
|
||||
contents, _ := json.Marshal(tokenFields)
|
||||
logrus.Tracef("User info from OIDC source %s: %v", o.name, string(contents))
|
||||
slog.Debug("OIDC user info",
|
||||
"source", o.name,
|
||||
"info", string(contents))
|
||||
}
|
||||
|
||||
return tokenFields, nil
|
||||
|
Reference in New Issue
Block a user