Skip to content
Draft
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
2 changes: 1 addition & 1 deletion cmd/authd/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/ubuntu/authd/internal/consts"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// initViperConfig sets verbosity level and add config env variables and file support based on name prefix.
Expand Down
2 changes: 1 addition & 1 deletion cmd/authd/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/spf13/viper"
"github.com/ubuntu/authd/internal/consts"
"github.com/ubuntu/authd/internal/daemon"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/services"
"github.com/ubuntu/authd/internal/users"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// cmdName is the binary name for the agent.
Expand Down
27 changes: 27 additions & 0 deletions docs/howto/configure-authd.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,33 @@ to which only the user with the [owner role](#configure-allowed-users) is added:
#owner_extra_groups =
```

(ref::device-registration)=
## Configure device registration

When using the Microsoft Entra ID broker, you can enable automatic device
registration, which allows administrators to manage registered devices in the
Microsoft Entra admin center.

Automatic device registration can be enabled with the `register_device`
option in the `msentraid` section of the broker configuration file:

```ini
[msentraid]
## Enable automatic device registration with Microsoft Entra ID
## when a user logs in through this broker.
##
## If set to true, authd will attempt to register the local machine
## as a device in Entra ID upon successful login.
##
## If set to false (the default), device registration will be skipped.
#register_device = false
```

```{note}
When changing this option, users are forced to re-authenticate via device
authentication on the next login.
```

## Restart the broker

When a configuration file is added you have to restart authd:
Expand Down
2 changes: 1 addition & 1 deletion examplebroker/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/godbus/dbus/v5"
"github.com/godbus/dbus/v5/introspect"
"github.com/ubuntu/decorate"
"github.com/ubuntu/authd/internal/decorate"
)

const (
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/ubuntu/decorate v0.0.0-20230606064312-bc4ac83958d6
go.etcd.io/bbolt v1.4.3
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/sys v0.39.0
Expand Down Expand Up @@ -55,7 +54,6 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
Expand Down
11 changes: 0 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5
github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo=
github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
Expand Down Expand Up @@ -75,7 +73,6 @@ github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand All @@ -88,8 +85,6 @@ github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDc
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
Expand All @@ -105,14 +100,10 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/ubuntu/decorate v0.0.0-20230606064312-bc4ac83958d6 h1:J0625LLHcZxxnnKCdr2iBbTtYjUiv6KkM6NpGisuQ3Q=
github.com/ubuntu/decorate v0.0.0-20230606064312-bc4ac83958d6/go.mod h1:edGgz97NOqS2oqzbKrZqO9YU9neosRrkEZbVJVQynAA=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
Expand All @@ -138,7 +129,6 @@ golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82/go.mod h1:Q9BGdFy1y4nkUwi
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
Expand All @@ -159,7 +149,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorbe.io/go/osrelease v0.3.0 h1:RqVqqfYMbe8AkTrCovTzE+FXYNolUFrhP/ne44za/xA=
Expand Down
2 changes: 1 addition & 1 deletion internal/brokers/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/godbus/dbus/v5"
"github.com/ubuntu/authd/internal/brokers/auth"
"github.com/ubuntu/authd/internal/brokers/layouts"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
"golang.org/x/exp/slices"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/brokers/dbusbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"

"github.com/godbus/dbus/v5"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/services/errmessages"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
"gopkg.in/ini.v1"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/brokers/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"sync"

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

// Manager is the object that manages the available brokers and the session->broker and user->broker relationships.
Expand Down
2 changes: 1 addition & 1 deletion internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/coreos/go-systemd/v22/activation"
"github.com/coreos/go-systemd/v22/daemon"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
"google.golang.org/grpc"
)

Expand Down
41 changes: 41 additions & 0 deletions internal/decorate/decorate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Package decorate contains various helpers to decorate errors with fewer lines of code in functions.
package decorate

import (
"context"
"fmt"

"github.com/ubuntu/authd/log"
)

// OnError prefixes any error with format/args.
func OnError(err *error, format string, args ...interface{}) {
if *err != nil {
s := fmt.Sprintf(format, args...)
*err = fmt.Errorf("%s: %w", s, *err)
}
}

// LogOnError logs only any errors without failing.
func LogOnError(err error) {
LogOnErrorContext(context.Background(), err)
}

// LogOnErrorContext logs any errors without failing. It takes a context.
func LogOnErrorContext(ctx context.Context, err error) {
if err != nil {
log.Warning(ctx, err)
}
}

// LogFuncOnError logs only any errors returned by f without failing.
func LogFuncOnError(f func() error) {
LogFuncOnErrorContext(context.Background(), f)
}

// LogFuncOnErrorContext logs only error returned by f without failing. It takes a context.
func LogFuncOnErrorContext(ctx context.Context, f func() error) {
if err := f(); err != nil {
log.Warning(ctx, err)
}
}
2 changes: 1 addition & 1 deletion internal/services/pam/pam.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/ubuntu/authd/internal/brokers"
"github.com/ubuntu/authd/internal/brokers/auth"
"github.com/ubuntu/authd/internal/brokers/layouts"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/proto/authd"
"github.com/ubuntu/authd/internal/services/permissions"
"github.com/ubuntu/authd/internal/users"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"errors"

"github.com/ubuntu/decorate"
"github.com/ubuntu/authd/internal/decorate"
"google.golang.org/grpc/peer"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/services/permissions/servercreds.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"math"
"net"

"github.com/ubuntu/decorate"
"github.com/ubuntu/authd/internal/decorate"
"golang.org/x/sys/unix"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down
2 changes: 1 addition & 1 deletion internal/users/db/bbolt/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"syscall"

"github.com/ubuntu/decorate"
"github.com/ubuntu/authd/internal/decorate"
"go.etcd.io/bbolt"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/users/db/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"
"strings"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/db/bbolt"
"github.com/ubuntu/authd/internal/users/localentries"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// MigrateFromBBoltToSQLite migrates data from bbolt to SQLite.
Expand Down
2 changes: 1 addition & 1 deletion internal/users/localentries/getgrent_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"syscall"
"unsafe"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/decorate"
)

// types.GroupEntry represents a group entry.
Expand Down
2 changes: 1 addition & 1 deletion internal/users/localentries/getpwent_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"sync"
"syscall"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/decorate"
)

var getpwentMu sync.Mutex
Expand Down
2 changes: 1 addition & 1 deletion internal/users/localentries/localgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"strconv"
"strings"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/fileutils"
"github.com/ubuntu/authd/internal/sliceutils"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// GetGroupEntries returns a copy of the current group entries.
Expand Down
2 changes: 1 addition & 1 deletion internal/users/localentries/localusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strconv"
"strings"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

func parseLocalPasswdFile(passwdFile string) (entries []types.UserEntry, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/users/localentries/lockedentries.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"strconv"
"sync"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/testsdetection"
userslocking "github.com/ubuntu/authd/internal/users/locking"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/users/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"sync"
"syscall"

"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/internal/users/db"
"github.com/ubuntu/authd/internal/users/localentries"
"github.com/ubuntu/authd/internal/users/tempentries"
"github.com/ubuntu/authd/internal/users/types"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// Config is the configuration for the user manager.
Expand Down
2 changes: 1 addition & 1 deletion pam/internal/dbusmodule/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/godbus/dbus/v5"
"github.com/msteinert/pam/v2"
"github.com/ubuntu/authd/internal/decorate"
"github.com/ubuntu/authd/log"
"github.com/ubuntu/decorate"
)

// Transaction is a [pam.Transaction] with dbus support.
Expand Down
Loading