Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log messages #334

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ func (b *Broker) handleIsAuthenticated(ctx context.Context, session *session, au
}

if !b.userNameIsAllowed(authInfo.UserInfo.Name) {
log.Warningf(context.Background(), "User %q is not in the list of allowed users", authInfo.UserInfo.Name)
return AuthDenied, errorMessage{Message: "permission denied"}
}

Expand Down Expand Up @@ -740,7 +741,7 @@ func (b *Broker) UserPreCheck(username string) (string, error) {
}

if !found {
return "", errors.New("username does not match the allowed suffixes")
return "", fmt.Errorf("username %q does not match any allowed suffix", username)
}

u := info.NewUser(username, filepath.Join(b.cfg.homeBaseDir, username), "", "", "", nil)
Expand Down
5 changes: 5 additions & 0 deletions internal/dbusservice/methods.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dbusservice

import (
"context"

"github.com/godbus/dbus/v5"
"github.com/ubuntu/authd/log"
)

// NewSession is the method through which the broker and the daemon will communicate once dbusInterface.NewSession is called.
Expand Down Expand Up @@ -35,8 +38,10 @@ func (s *Service) SelectAuthenticationMode(sessionID, authenticationModeName str
func (s *Service) IsAuthenticated(sessionID, authenticationData string) (access, data string, dbusErr *dbus.Error) {
access, data, err := s.broker.IsAuthenticated(sessionID, authenticationData)
if err != nil {
log.Warningf(context.Background(), "IsAuthenticated error: %v", err)
return "", "", dbus.MakeFailedError(err)
}
log.Debugf(context.Background(), "IsAuthenticated: %s", access)
return access, data, nil
}

Expand Down
Loading