mirror of
https://github.com/hanzo-fi/go-libs.git
synced 2026-10-30 20:53:44 +00:00
43 lines
829 B
Go
43 lines
829 B
Go
package audit
|
|
|
|
import (
|
|
"github.com/hanzo-fi/go-libs/v5/pkg/authn/oidc"
|
|
)
|
|
|
|
type Options struct {
|
|
KeySets map[string]oidc.KeySet
|
|
OrganizationID string
|
|
StackID string
|
|
}
|
|
|
|
type Option func(*Options)
|
|
|
|
// WithAuth enables JWT claims extraction from the Authorization header.
|
|
func WithAuth(keySets map[string]oidc.KeySet) Option {
|
|
return func(o *Options) {
|
|
o.KeySets = keySets
|
|
}
|
|
}
|
|
|
|
// WithOrganizationID sets the organization ID included in audit events.
|
|
func WithOrganizationID(id string) Option {
|
|
return func(o *Options) {
|
|
o.OrganizationID = id
|
|
}
|
|
}
|
|
|
|
// WithStackID sets the stack ID included in audit events.
|
|
func WithStackID(id string) Option {
|
|
return func(o *Options) {
|
|
o.StackID = id
|
|
}
|
|
}
|
|
|
|
func NewOptions(opts ...Option) *Options {
|
|
o := &Options{}
|
|
for _, opt := range opts {
|
|
opt(o)
|
|
}
|
|
return o
|
|
}
|