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:
Timothy Messier committed 2022-09-07 17:53:39 +00:00
1 parent e4bb847ad1
commit 2fbdcf6ce0
7 files changed
+184 -414

No files matched your search

+10
View File
@@ -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
}
}