Auth Method list pagination (#4165)

* wip

* implement list pagination for auth methods

* remove unused code

* update tests to fix sorting

* address PR comments

* simplify query, add token tests

* change test name

* wip sql testing

* add boolean column to indicate whether auth methods should be returned to unauthenticated users, remove secrets from api response

* is_active_public not null

* remove secrets and unwrapping

* move not null to immediately after data migration

* order public_id descending

* fix(db): Fix auth method migrations (#4193)

* wip

* fix db tests

* fix failing api tests

* reverse order of create time and update time in test

---------

Co-authored-by: Michael Gaffney <mike@gaffney.cc>
This commit is contained in:
Michael MiltonandMichael Gaffney authored and Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:21 -08:00
1 parent 0fad770d8a
commit 8d50a0913f
34 files changed
+4340 -445

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package auth
import (
"context"
"github.com/hashicorp/boundary/internal/pagination"
)
// The option type is how options are passed as arugments
type Option func(*Options) error
// Options is a struct that contains all the possible auth options
type Options struct {
WithLimit int
WithStartPageAfterItem pagination.Item
WithUnauthenticatedUser bool
}
// getDefaultOptions returns a new Options struct
func getDefaultOptions() *Options {
return &Options{}
}
// GetOpts loops over the options and provides
// the configured options struct
func GetOpts(opts ...Option) (*Options, error) {
newOpts := getDefaultOptions()
for _, opt := range opts {
if err := opt(newOpts); err != nil {
return nil, err
}
}
return newOpts, nil
}
// WithLimit provides an option to provide a limit.
// If WithLimit <= 0, then default limits are used for results.
func WithLimit(_ context.Context, l int) Option {
return func(o *Options) error {
o.WithLimit = l
return nil
}
}
// WithStartPageAfterItem is used to paginate over the results.
// The next page will start after the provided item.
func WithStartPageAfterItem(_ context.Context, item pagination.Item) Option {
return func(o *Options) error {
o.WithStartPageAfterItem = item
return nil
}
}
// WithUnauthenticatedUser provides an option for filtering results for
// an unauthenticated users.
func WithUnauthenticatedUser(_ context.Context, enabled bool) Option {
return func(o *Options) error {
o.WithUnauthenticatedUser = enabled
return nil
}
}