Commit Graph

55 Commits

Author SHA1 Message Date
jkoberg
af2a4c2c97 check public link authorization first
Signed-off-by: jkoberg <jkoberg@owncloud.com>
2023-07-26 15:02:38 +02:00
Daniël Franke
8f7521eff7 Move away from global tracers. (#6591)
* Move away from global tracers.

This PR moves away from global tracers and instead initialises
a tracer provider at Service setup and passes it where it needs to be.

* Change tracing provider to be set via options.

Also change name for GetServiceTraceProvider.

* Add changelog.
2023-06-23 14:20:26 +02:00
Jörn Friedrich Dreyer
f40b538d9d use otelhttp tracing middleware
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-06-08 17:42:02 +02:00
Florian Schade
4f26424db6 [full-ci] enhancement: use reva client pool selectors (#6452)
* enhancement: use reva client pool selectors

register mock service to registry and pass tests

* enhancement: bump reva

* Fix a couple of linter issues

---------

Co-authored-by: Ralf Haferkamp <rhaferkamp@owncloud.com>
2023-06-08 12:41:04 +02:00
jkoberg
d347448ec0 remove duplicated sutureservice code
Signed-off-by: jkoberg <jkoberg@owncloud.com>
2023-06-02 12:02:27 +02:00
Ralf Haferkamp
7a4bc71e65 Revert "idp/proxy: Match users by ID instead of name by default"
This reverts commit 52951b42b0.

The change broke authentication for at least the desktop client when
using the builtin idp. There seem to be issues in the IDP (lico) which
result in the implicit scoped not being added correctly in some case.
When that scope is missing the `lg.uuid` claim will not be present in
the userinfo and we can correctly match users by id.

This reverts back to the old behaviour of matching users by name. Which
also brings some aspects of https://github.com/owncloud/ocis/issues/904

Fixes #6415
2023-06-01 11:13:47 +02:00
Jörn Friedrich Dreyer
632b206675 trace proxie middlewares (#6313)
* trace proxie middlewares

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Update ocis-pkg/service/grpc/client.go

Co-authored-by: Christian Richter <1058116+dragonchaser@users.noreply.github.com>

* default tls is off

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Co-authored-by: Christian Richter <1058116+dragonchaser@users.noreply.github.com>
2023-05-27 10:18:24 +02:00
Ralf Haferkamp
52951b42b0 idp/proxy: Match users by ID instead of name by default
Reconfigure the oidc clients for lico, so that lico adds the "lg.uuid" to
tokens and userinfo by default. That claim will contain the userid. So
we can now use the userid for matching users when using the default
idm/idp configuration. This fixes further problems so that users being
recreated with the same name are correctly treated as differnt users.

Fixes: #904
2023-05-23 09:48:47 +02:00
Ralf Haferkamp
b7990875c1 oidc: Remove "aud" claim validation of logout tokens (#6156)
The "aud" claim of the logout token is supposed to contain the client-id
of the client for which the token was issued. Our current implementation of
validating that claim is somewhat broken. We only allow to configure a single
value for the allowed client id. But we have different client-ids
accessing oCIS.

This completely removes the current validation of the `aud` claim until
we come up with a working solution. As we currently require a session id
to be present in the logout token the risk not validating the `aud`
claim is pretty low.

Related: #6149
2023-04-27 10:34:09 +02:00
Andre Duffeck
77bb3d8bcd [full-ci] Refactor stores (#6019)
* Streamline the store implementation with and into reva

* Adapt to the cache/store refactoring in reva

* Streamline config options and their env vars

* Apply suggestions from code review

Co-authored-by: Martin <github@diemattels.at>

* Use the same database for all stores

* Bump reva

* Configure stat and filemetadata cache separately

* Fix default config

---------

Co-authored-by: Martin <github@diemattels.at>
2023-04-24 15:13:35 +02:00
Ralf Haferkamp
70a80125c3 Fix backchannel logout
Use access token to lookup session id. The userinfo endpoint does
not return the session id. Also add some debug logging.

Co-authored-by: Christian Richter <crichter@owncloud.com>
Co-authored-by: Michael Barz <mbarz@owncloud.com>
2023-04-20 18:04:52 +02:00
Christian Richter
cec99493f2 Add workaround for chiRouter racecondition in chi.RegisterMethod()
Co-authored-by: Ralf Haferkamp <rhaferkamp@owncloud.com>
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-20 10:19:05 +02:00
Christian Richter
30bcf32062 incorporate requested changes
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-20 09:00:58 +02:00
Christian Richter
3d6d4c7c7c add missing http method
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:50 +02:00
Christian Richter
e88a0d7bc3 add tests for oidc backchannel logout
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:49 +02:00
Christian Richter
15691ae78a fix contexts, render result
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
d2d7c49df4 properly parse logout request
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
dc399a61ac implement backchannel logout, reuse useringo cache
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Christian Richter
a900d0ed8d Refactor caches
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
bc15b8a396 work on logout
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
b608d0b0f9 move verify access token code to oidc client
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
58dce9bed8 use our oidc client
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
97894acccd add missing error check, redirect stub
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Christian Richter
a3640b0565 extract full claims from jwt token to get session id
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:23 +02:00
Ralf Haferkamp
6059747491 proxy: Rework oidc role mapper to allow multiple matching roles
If multiple claims values have a valid matching for ocis roles, we'll pick
the ocis role that appears first in the mapping configuration.
2023-04-19 08:56:47 +02:00
Jörn Friedrich Dreyer
6bec87f582 Proxy accesstoken cache store (#5829)
* refactor middleware options

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use ocmemstore micro store implementaiton for token cache

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* refactor ocis store options, support redis sentinel

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* align cache configuration

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* database and tabe are used to build prefixes for inmemory stores

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add global persistent store options to userlog config

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* log cache errors but continue

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* drup unnecessary type conversion

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Better description for the default userinfo ttl

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use global cache options for even more caches

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* don't log userinfo cache misses

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* default to stock memory store

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use correct mem store typo string

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* split cache options, doc cleanup

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* mint and write userinfo to cache async

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use hashed token as key

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* go mod tidy

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update docs

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update cache store naming

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* bring back depreceted ocis-pkg/store package for backwards compatability

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Apply suggestions from code review

Co-authored-by: kobergj <jkoberg@owncloud.com>

* revert ocis-pkg/cache to store rename

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add waiting for each step 50 milliseconds

* starlack check

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Co-authored-by: kobergj <jkoberg@owncloud.com>
Co-authored-by: Viktor Scharf <scharf.vi@gmail.com>
2023-03-22 15:21:57 +01:00
Ralf Haferkamp
a448c75c75 Extract role assignments from claims
Add a UserRoleAssigner implementation that extract role names from the
users' claims and creates role assignments in the settings service based
on a configured mapping of claim values to ocis role names.

Closes: #5669
2023-03-20 15:12:09 +01:00
Ralf Haferkamp
d57d52b33d proxy: Add an interface for user role assignment
This moves the lookup and the creation of the users' role assignemt out
of the user backend into its own interface. This makes the user backend
a bit simpler and allows to provide different implemenation for the user
role assignment more easily.
2023-03-20 15:12:09 +01:00
Ralf Haferkamp
490a835a3a proxy: Move CS3 User backend options to "functional" options
This will make it easier to add/remove options to the backend in the
future.
2023-03-20 15:12:09 +01:00
Ralf Haferkamp
88e8bb1b72 account_resolver: Handle user roles separately from user lookup
This removes the "withRoles" flag from the GetUserByClaims lookup and move the
functionality into a separate method. This should make the code a bit more readable
in preparation for maintaining the RoleAssignments from OIDC claims.
2023-03-20 15:12:09 +01:00
Florian Schade
f38a9f4385 Introduce Policies-Service (#5716)
* add policies service
add policies proxy middleware
add policies event service
add policies grpc service
prepare ci and git environments (ci, make, readme, doc)

* add webfinger to the drone conf

* fix docs
remove not used virus scan postprocessing step

* relocate example rego file
implicitly enable and disable proxy and postprocessing policy checking by setting the query.
update configuration descriptions

* move policies
update readme

* use converter func to convert pp environment to actual environment
expose and test custom rego functions
add engine unit tests
add opa unit tests
update policies readme

Co-authored-by: Martin <github@diemattels.at>

* relocate sample policies to the deployments folder
change and document policies service port

* update index.md and small fix

* add health command
add version command
add debug server

---------

Co-authored-by: Martin <github@diemattels.at>
2023-03-14 16:08:22 +01:00
David Christofas
67549b4ebd add config option to set default quota per role 2023-02-22 16:22:45 +01:00
Jörn Friedrich Dreyer
3aa864aecc Remove Staticcheck warnings (#5394)
* remove deprecated ioutil imports

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* remove duplicate imports

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* remove unused values

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* remove some unused types

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* remove deprecated ioutil import

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-01-13 15:29:14 +01:00
Jörn Friedrich Dreyer
0f7dba53fb use min tls 1.2 (#4969)
* use min tls 1.2

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2022-11-03 16:08:56 +01:00
Ralf Haferkamp
b24d126b30 Introduce TLS Settings for go-micro based http services
TLS for the services can be configure by setting the "OCIS_HTTP_TLS_ENABLED",
"OCIS_HTTP_TLS_CERTIFICATE" and "OCIS_HTTP_TLS_KEY" environment variables.
Currently the ocis proxy is this only service that directly accesses backend
services. It determines whether to use TLS or not by looking a the new registry
metadata "use_tls". As specific CA Cert for certificate verification
can be set with the "PROXY_HTTPS_CACERT" environment variable.
2022-11-03 11:58:53 +01:00
Ralf Haferkamp
ee974afebf [full-ci] Introduce TLS Settings for go-micro based grpc services and clients (#4901)
* Introduce TLS Settings for go-micro based grpc services and clients

TLS for the services can be configure by setting the OCIS_MICRO_GRPC_TLS_ENABLED"
"OCIS_MICRO_GRPC_TLS_CERTIFICATE" and "OCIS_MICRO_GRPC_TLS_KEY"
enviroment variables.

TLS for the clients can configured by setting the "OCIS_MICRO_GRPC_CLIENT_TLS_MODE"
and "OCIS_MICRO_GRPC_CLIENT_TLS_CACERT" variables.

By default TLS is disabled.

Co-authored-by: Martin <github@diemattels.at>

* Unify TLS configuration for all grpc services

All grpc service (whether they're based on reva) or go-micro use the
same set of config vars now.

TLS for the services can be configure by setting the OCIS_GRPC_TLS_ENABLED,
OCIS_GRPC_TLS_CERTIFICATE and OCIS_GRPC_TLS_KEY enviroment variables.

TLS for the clients can configured by setting the OCIS_GRPC_CLIENT_TLS_MODE
and OCIS_MICRO_GRPC_CLIENT_TLS_CACERT variables.

There are no individual per service config vars currently. If really
needed, per service tls configurations can be specified via config file.

Co-authored-by: Martin <github@diemattels.at>

Co-authored-by: Martin <github@diemattels.at>
2022-11-03 10:17:08 +01:00
Ralf Haferkamp
3d57f5cc21 Introduce TLS Settings for all reva grpc services and clients 2022-10-25 11:50:08 +02:00
Ralf Haferkamp
083b9897a0 proxy: Use reva provided method for getting Gateway Client
This removes some duplicated code. And reuses the reva client code
we're also using everywhere else.
2022-10-05 08:45:05 +02:00
Ralf Haferkamp
01650a5023 Use lazy initialization for the default grpc client
This avoids using a public global variable. It allows us to initialize
the default client a bit later (outside of init()). That way we can e.g.
properly initialize the in-memory registry.
2022-09-26 16:25:56 +02:00
David Christofas
4d4f3a16e1 refactor proxy code
I refactored the proxy so that we execute the routing before the
authentication middleware. This is necessary so that we can determine
which routes are considered unprotected i.e. which routes don't need
authentication.
2022-09-01 12:43:32 +02:00
David Christofas
c4881f5736 Merge pull request #4374 from owncloud/rewrite-auth-middleware
[full-ci] Rewrite of the authentication middleware
2022-08-22 16:39:03 +02:00
Willy Kloucek
9f2be9f4f9 remove Log prefix from configlog functions 2022-08-22 08:08:18 +02:00
Willy Kloucek
e58eaabdeb move config parse error logging into function to ensure new lines and don't parse config for help 2022-08-18 15:27:28 +02:00
Willy Kloucek
60689c9c1a improve unsupervised description 2022-08-18 10:59:35 +02:00
Willy Kloucek
6154466bbc rename extensions to services (leftover occurences) 2022-08-17 15:36:52 +02:00
David Christofas
06ffd9cf8a some more cleaning up 2022-08-12 10:48:21 +02:00
David Christofas
f35c8b9205 clean up the authenticators middlewares 2022-08-12 10:47:48 +02:00
David Christofas
e96819bce8 rewrite the auth middleware
The old approach of the authentication middlewares had the problem that when an authenticator could not authenticate a request it would still send it to the next handler, in case that the next one can authenticate it. But if no authenticator could successfully authenticate the request, it would still be handled, which leads to unauthorized access.
2022-08-12 10:47:43 +02:00
Willy Kloucek
94646c8060 add middleware to rewrite the /.well-known/openid-configuration endpoint for external idps 2022-08-05 14:12:01 +02:00
Ralf Haferkamp
8229567213 Allow to configure the JWKS refresh settings
This exposes a couple for knobs for the jwks keyfunc module to adjust
timeout and refresh intervals.
2022-08-03 12:00:31 +02:00