Files
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

65 lines
1.6 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package auth
import (
"context"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/pagination"
)
// The option type is how options are passed as arguments
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
}
}