feat(session): Use permissions for limiting list results
The session repository can now be passed an optional set of permissions. The permissions are used to restrict results from the repository. Currently this only impacts the List method. This enabled the sessions service to use a single query to retrieve sessions and replaces the previous behavior where the session service would first request all sessions for a given set of scopes, evaluate the permissions, and then request sessions based on a set of session ids.
This commit is contained in:
7 files changed
+184
-414
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
)
|
||||
|
||||
// getOpts - iterate the inbound Options and return a struct
|
||||
@@ -32,6 +33,7 @@ type options struct {
|
||||
withDbOpts []db.Option
|
||||
withWorkerStateDelay time.Duration
|
||||
withTerminated bool
|
||||
withPermissions *perms.UserPermissions
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
@@ -120,3 +122,11 @@ func WithTerminated(withTerminated bool) Option {
|
||||
o.withTerminated = withTerminated
|
||||
}
|
||||
}
|
||||
|
||||
// WithPermissions is used to include user permissions when constructing a
|
||||
// Repository.
|
||||
func WithPermissions(p *perms.UserPermissions) Option {
|
||||
return func(o *options) {
|
||||
o.withPermissions = p
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user