* feat: Implemet the vault-storage feat: Separate the storage-users and graph to handle feat: move the space create cache configurate the vault srorage Postprocessing hide the assignment of the MountID to VaultStorageProviderID behind a flag to avoid the ID mismatch configurate the proxy to create the vault home space update the filter Make the graph able to handle vault prefix. no extra service needed apply the vault filter to sharedbyme and sharedwithme added vault-storage docker use squashed reva fix the finishUpload event restict webdav copy/move from the vault feat: provide the mfa to webdav and grpc feat: refactoring: provide the mfa to webdav and grpc mfa collaboration fix GetRootDriveChildren and more fix: send the MFA header in HTTP clients from the collaboration service provide the default storage user vault configuration update create_home middleware Update deployments/examples/ocis_full/vault-storage.yml Co-authored-by: Martin <github@diemattels.at> Update services/gateway/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update services/graph/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update services/graph/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update services/storage-users/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update services/proxy/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update services/storage-users/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> Update deployments/examples/ocis_full/vault-storage.yml Co-authored-by: Martin <github@diemattels.at> bump reva deduplicate the requireMFA middeware on vault routes. fix AppendPlainToOpaque. added the changlog and comments * feat: add the vault mode search * Update changelog/unreleased/enhancement-vault-storage.md Co-authored-by: Martin <github@diemattels.at> * update the readme. the reva vault storage provider configuration disabled by default * feat: [OCISDEV-531] add vault capabilities to the OCS capabilities endpoint * the port range allocated. the configuration updated. --------- Co-authored-by: Martin <github@diemattels.at>
307 lines
9.1 KiB
Go
307 lines
9.1 KiB
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
|
|
policiessvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/policies/v0"
|
|
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
|
"github.com/owncloud/ocis/v2/services/proxy/pkg/config"
|
|
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend"
|
|
"github.com/owncloud/ocis/v2/services/proxy/pkg/userroles"
|
|
"github.com/owncloud/reva/v2/pkg/events"
|
|
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
|
|
"go-micro.dev/v4/store"
|
|
"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 to use for logging, must be set
|
|
Logger log.Logger
|
|
// PolicySelectorConfig for using the policy selector
|
|
PolicySelector config.PolicySelector
|
|
// HTTPClient to use for communication with the oidcAuth provider
|
|
HTTPClient *http.Client
|
|
// UserProvider backend to use for resolving User
|
|
UserProvider backend.UserBackend
|
|
// UserRoleAssigner to user for assign a users default role
|
|
UserRoleAssigner userroles.UserRoleAssigner
|
|
// SettingsRoleService for the roles API in settings
|
|
SettingsRoleService settingssvc.RoleService
|
|
// PoliciesProviderService for policy evaluation
|
|
PoliciesProviderService policiessvc.PoliciesProviderService
|
|
// OIDCClient to fetch user info and verify tokens, must be set for the oidc_auth middleware
|
|
OIDCClient oidc.OIDCClient
|
|
// OIDCIss is the oidcAuth-issuer
|
|
OIDCIss string
|
|
// RevaGatewaySelector to send requests to the reva gateway
|
|
RevaGatewaySelector pool.Selectable[gateway.GatewayAPIClient]
|
|
// PreSignedURLConfig to configure the middleware
|
|
PreSignedURLConfig config.PreSignedURL
|
|
// UserOIDCClaim to read from the oidc claims
|
|
UserOIDCClaim string
|
|
// UserCS3Claim to use when looking up a user in the CS3 API
|
|
UserCS3Claim string
|
|
// AutoprovisionAccounts when an accountResolver does not exist.
|
|
AutoprovisionAccounts bool
|
|
// EnableBasicAuth to allow basic auth
|
|
EnableBasicAuth bool
|
|
// AllowAppAuth specifies whether authentication using application tokens is permitted.
|
|
AllowAppAuth bool
|
|
// DefaultAccessTokenTTL is used to calculate the expiration when an access token has no expiration set
|
|
DefaultAccessTokenTTL time.Duration
|
|
// UserInfoCache sets the access token cache store
|
|
UserInfoCache store.Store
|
|
// MFAStore is used to persist verified MFA status so that non-OIDC
|
|
// requests (e.g. signed-URL archiver downloads) can inherit the status
|
|
// from the user's most recent OIDC-authenticated session.
|
|
MFAStore store.Store
|
|
// CredentialsByUserAgent sets the auth challenges on a per user-agent basis
|
|
CredentialsByUserAgent map[string]string
|
|
// AccessTokenVerifyMethod configures how access_tokens should be verified but the oidc_auth middleware.
|
|
// Possible values currently: "jwt" and "none"
|
|
AccessTokenVerifyMethod string
|
|
// JWKS sets the options for fetching the JWKS from the IDP
|
|
JWKS config.JWKS
|
|
// RoleQuotas hold userid:quota mappings. These will be used when provisioning new users.
|
|
// The users will get as much quota as is set for their role.
|
|
RoleQuotas map[string]uint64
|
|
// EnableVaultMode creates a new vault home for the user if it does not exist.
|
|
EnableVaultMode bool
|
|
// TraceProvider sets the tracing provider.
|
|
TraceProvider trace.TracerProvider
|
|
// SkipUserInfo prevents the oidc middleware from querying the userinfo endpoint and read any claims directly from the access token instead
|
|
SkipUserInfo bool
|
|
EventsPublisher events.Publisher
|
|
// Service Accounts
|
|
ServiceAccountID string
|
|
ServiceAccountSecret string
|
|
// Multi-Instance Options
|
|
MultiInstanceEnabled bool
|
|
InstanceID string
|
|
MasterID string
|
|
MemberClaim string
|
|
GuestClaim string
|
|
GuestRoleName string
|
|
}
|
|
|
|
// 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
|
|
}
|
|
}
|
|
|
|
// PolicySelectorConfig provides a function to set the policy selector config option.
|
|
func PolicySelectorConfig(cfg config.PolicySelector) Option {
|
|
return func(o *Options) {
|
|
o.PolicySelector = cfg
|
|
}
|
|
}
|
|
|
|
// HTTPClient provides a function to set the http client config option.
|
|
func HTTPClient(c *http.Client) Option {
|
|
return func(o *Options) {
|
|
o.HTTPClient = c
|
|
}
|
|
}
|
|
|
|
// SettingsRoleService provides a function to set the role service option.
|
|
func SettingsRoleService(rc settingssvc.RoleService) Option {
|
|
return func(o *Options) {
|
|
o.SettingsRoleService = rc
|
|
}
|
|
}
|
|
|
|
// PoliciesProviderService provides a function to set the policies provider option.
|
|
func PoliciesProviderService(pps policiessvc.PoliciesProviderService) Option {
|
|
return func(o *Options) {
|
|
o.PoliciesProviderService = pps
|
|
}
|
|
}
|
|
|
|
// OIDCClient provides a function to set the oidc client option.
|
|
func OIDCClient(val oidc.OIDCClient) Option {
|
|
return func(o *Options) {
|
|
o.OIDCClient = val
|
|
}
|
|
}
|
|
|
|
// OIDCIss sets the oidcAuth issuer url
|
|
func OIDCIss(iss string) Option {
|
|
return func(o *Options) {
|
|
o.OIDCIss = iss
|
|
}
|
|
}
|
|
|
|
// CredentialsByUserAgent sets UserAgentChallenges.
|
|
func CredentialsByUserAgent(v map[string]string) Option {
|
|
return func(o *Options) {
|
|
o.CredentialsByUserAgent = v
|
|
}
|
|
}
|
|
|
|
// WithRevaGatewaySelector provides a function to set the reva gateway service selector option.
|
|
func WithRevaGatewaySelector(val pool.Selectable[gateway.GatewayAPIClient]) Option {
|
|
return func(o *Options) {
|
|
o.RevaGatewaySelector = val
|
|
}
|
|
}
|
|
|
|
// PreSignedURLConfig provides a function to set the PreSignedURL config
|
|
func PreSignedURLConfig(cfg config.PreSignedURL) Option {
|
|
return func(o *Options) {
|
|
o.PreSignedURLConfig = cfg
|
|
}
|
|
}
|
|
|
|
// UserOIDCClaim provides a function to set the UserClaim config
|
|
func UserOIDCClaim(val string) Option {
|
|
return func(o *Options) {
|
|
o.UserOIDCClaim = val
|
|
}
|
|
}
|
|
|
|
// UserCS3Claim provides a function to set the UserClaimType config
|
|
func UserCS3Claim(val string) Option {
|
|
return func(o *Options) {
|
|
o.UserCS3Claim = val
|
|
}
|
|
}
|
|
|
|
// AutoprovisionAccounts provides a function to set the AutoprovisionAccounts config
|
|
func AutoprovisionAccounts(val bool) Option {
|
|
return func(o *Options) {
|
|
o.AutoprovisionAccounts = val
|
|
}
|
|
}
|
|
|
|
// EnableBasicAuth provides a function to set the EnableBasicAuth config
|
|
func EnableBasicAuth(enableBasicAuth bool) Option {
|
|
return func(o *Options) {
|
|
o.EnableBasicAuth = enableBasicAuth
|
|
}
|
|
}
|
|
|
|
// AllowAppAuth provides a function to set the AllowAppAuth config
|
|
func AllowAppAuth(allowAppAuth bool) Option {
|
|
return func(o *Options) {
|
|
o.AllowAppAuth = allowAppAuth
|
|
}
|
|
}
|
|
|
|
// DefaultAccessTokenTTL provides a function to set the DefaultAccessTokenTTL
|
|
func DefaultAccessTokenTTL(ttl time.Duration) Option {
|
|
return func(o *Options) {
|
|
o.DefaultAccessTokenTTL = ttl
|
|
}
|
|
}
|
|
|
|
// UserInfoCache provides a function to set the UserInfoCache
|
|
func UserInfoCache(val store.Store) Option {
|
|
return func(o *Options) {
|
|
o.UserInfoCache = val
|
|
}
|
|
}
|
|
|
|
// MFAStore provides a function to set the MFA session store.
|
|
func MFAStore(val store.Store) Option {
|
|
return func(o *Options) {
|
|
o.MFAStore = val
|
|
}
|
|
}
|
|
|
|
// UserProvider sets the accounts user provider
|
|
func UserProvider(up backend.UserBackend) Option {
|
|
return func(o *Options) {
|
|
o.UserProvider = up
|
|
}
|
|
}
|
|
|
|
// UserRoleAssigner sets the mechanism for assigning the default user roles
|
|
func UserRoleAssigner(ra userroles.UserRoleAssigner) Option {
|
|
return func(o *Options) {
|
|
o.UserRoleAssigner = ra
|
|
}
|
|
}
|
|
|
|
// AccessTokenVerifyMethod set the mechanism for access token verification
|
|
func AccessTokenVerifyMethod(method string) Option {
|
|
return func(o *Options) {
|
|
o.AccessTokenVerifyMethod = method
|
|
}
|
|
}
|
|
|
|
// RoleQuotas sets the role quota mapping setting
|
|
func RoleQuotas(roleQuotas map[string]uint64) Option {
|
|
return func(o *Options) {
|
|
o.RoleQuotas = roleQuotas
|
|
}
|
|
}
|
|
|
|
// EnableVaultMode sets the enable vault mode flag
|
|
func EnableVaultMode(enableVaultMode bool) Option {
|
|
return func(o *Options) {
|
|
o.EnableVaultMode = enableVaultMode
|
|
}
|
|
}
|
|
|
|
// TraceProvider sets the tracing provider.
|
|
func TraceProvider(tp trace.TracerProvider) Option {
|
|
return func(o *Options) {
|
|
o.TraceProvider = tp
|
|
}
|
|
}
|
|
|
|
// SkipUserInfo sets the skipUserInfo flag.
|
|
func SkipUserInfo(val bool) Option {
|
|
return func(o *Options) {
|
|
o.SkipUserInfo = val
|
|
}
|
|
}
|
|
|
|
// EventsPublisher sets the events publisher.
|
|
func EventsPublisher(ep events.Publisher) Option {
|
|
return func(o *Options) {
|
|
o.EventsPublisher = ep
|
|
}
|
|
}
|
|
|
|
// ServiceAccount sets the service account user
|
|
func ServiceAccount(id string, secret string) Option {
|
|
return func(o *Options) {
|
|
o.ServiceAccountID = id
|
|
o.ServiceAccountSecret = secret
|
|
}
|
|
}
|
|
|
|
// MultiInstance sets muli-instance options
|
|
func MultiInstance(enabled bool, iid string, masterID string, memberClaim, guestClaim string, guestRole string) Option {
|
|
return func(o *Options) {
|
|
o.MultiInstanceEnabled = enabled
|
|
o.InstanceID = iid
|
|
o.MasterID = masterID
|
|
o.MemberClaim = memberClaim
|
|
o.GuestClaim = guestClaim
|
|
o.GuestRoleName = guestRole
|
|
}
|
|
}
|