mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-15 16:51:44 -05:00
* primitive implementation to demonstrate how it could work, still to be considered WIP at best * add new dependency: MicahParks/jwkset and MicahParks/keyfunc to retrieve the JWK set from KeyCloak to verify the signature of the JWTs sent as part of Bearer authentication in the /auth API * (minor) opencloud/.../service.go: clean up a logging statement that was introduced earlier to hunt down why the auth-api service was not being started
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package svc
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/log"
|
|
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/config"
|
|
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/metrics"
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
// Option defines a single option function.
|
|
type Option func(o *Options)
|
|
|
|
// Options defines the available options for this package.
|
|
type Options struct {
|
|
Logger log.Logger
|
|
Config *config.Config
|
|
Middleware []func(http.Handler) http.Handler
|
|
Metrics *metrics.Metrics
|
|
TraceProvider trace.TracerProvider
|
|
}
|
|
|
|
// newOptions initializes the available default options.
|
|
func newOptions(opts ...Option) Options {
|
|
opt := Options{}
|
|
|
|
for _, o := range opts {
|
|
o(&opt)
|
|
}
|
|
|
|
return opt
|
|
}
|
|
|
|
// Logger provides a function to set the logger option.
|
|
func Logger(val log.Logger) Option {
|
|
return func(o *Options) {
|
|
o.Logger = val
|
|
}
|
|
}
|
|
|
|
// Config provides a function to set the config option.
|
|
func Config(val *config.Config) Option {
|
|
return func(o *Options) {
|
|
o.Config = val
|
|
}
|
|
}
|
|
|
|
// Middleware provides a function to set the middleware option.
|
|
func Middleware(val ...func(http.Handler) http.Handler) Option {
|
|
return func(o *Options) {
|
|
o.Middleware = val
|
|
}
|
|
}
|
|
|
|
func TraceProvider(tp trace.TracerProvider) Option {
|
|
return func(o *Options) {
|
|
o.TraceProvider = tp
|
|
}
|
|
}
|
|
|
|
func Metrics(m *metrics.Metrics) Option {
|
|
return func(o *Options) {
|
|
o.Metrics = m
|
|
}
|
|
}
|