mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-30 08:51:26 -05:00
- adds an access token middleware to read the x-access-token header, extract the reva user from it and store it in the context - implments the ocs/v[12].php/cloud/user/signing-key endpoint - reads or creates signing key in ocis-store Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
43 lines
955 B
Go
43 lines
955 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/owncloud/ocis-ocs/pkg/config"
|
|
"github.com/owncloud/ocis-pkg/v2/log"
|
|
)
|
|
|
|
// Option defines a single option function.
|
|
type Option func(o *Options)
|
|
|
|
// Options defines the available options for this package.
|
|
type Options struct {
|
|
// Logger to use for logging, must be set
|
|
Logger log.Logger
|
|
// TokenManagerConfig for communicating with the reva token manager
|
|
TokenManagerConfig config.TokenManager
|
|
}
|
|
|
|
// 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(l log.Logger) Option {
|
|
return func(o *Options) {
|
|
o.Logger = l
|
|
}
|
|
}
|
|
|
|
// TokenManagerConfig provides a function to set the token manger config option.
|
|
func TokenManagerConfig(cfg config.TokenManager) Option {
|
|
return func(o *Options) {
|
|
o.TokenManagerConfig = cfg
|
|
}
|
|
}
|