Commit Graph

58 Commits

Author SHA1 Message Date
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
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
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
Ralf Haferkamp
f5cfa7e126 proxy: Move to mockery for generating mocks
To align with what we're using everywhere else.
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
Ralf Haferkamp
a34a3b2a98 Cleanup some oidc related bits (#5751)
* Remove unused code from oidc module

* Use already existing Metadata type for jwks discovery

ocis-pkg/oidc already provides a type for the oidc metadata. Switch to
that instead of defining yet another custom type.

* oidc: Add helper to get IDP metadata
2023-03-07 14:43:42 +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
53d15d329e remove deprecated use of ioutil (#5205)
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2022-12-08 14:44:53 +01:00
Willy Kloucek
0ba134dbf6 discard errors 2022-11-24 17:07:01 +01:00
Willy Kloucek
c6b61cd347 remove any limits 2022-11-24 16:48:25 +01:00
Willy Kloucek
2e2e0cd4b6 fix HTTP1.1 RFC 2616 for bodies smaller than 1GB 2022-11-24 14:09:02 +01:00
Michael Barz
f84fbdd6ff corrections from code review 2022-10-17 17:22:33 +02:00
Jannik Stehle
e053f70950 Fix unit tests 2022-10-04 09:18:36 +02:00
Jannik Stehle
dd2abc94ee Make the tokeninfo endpoint unprotected as it is supposed to be available to the public 2022-10-04 09:18:36 +02:00
Ralf Haferkamp
e4c28def8a Request revatoken via machine auth after autoprovsioning user (#4690)
To successfully authenticate a user after it was autoprovisioned, we
need to get a valid reva token.

Fixes: #4616
2022-09-27 21:51:18 +02:00
David Christofas
20026faac2 fix wopi access to publicly shared files 2022-09-22 08:27:41 +02:00
Willy Kloucek
2d16779652 fix the oidc provider cache 2022-09-16 12:34:12 +02:00
Ralf Haferkamp
2c6eb888a8 proxy: Clarify comment 2022-09-07 14:30:19 +02:00
Ralf Haferkamp
ab0c82311a proxy: Fix archiver for public links
Allows /archiver to be used the "public-token" auth middleware. The
archiver is a bit of a special case, because it can be uses in several
ways: using 'normal' authentication (basic, oidc), using signed-urls or
using sharetokens. As only the "sharetoken" part is handled by the
"PublicShareAuth" middleware, we needed to special-case it a bit.
2022-09-07 14:30:19 +02:00
David Christofas
69ba80562e add unprotected flag to the proxy routes
I added an unprotected flag to the proxy routes which is evaluated by
the authentication middleware. This way we won't have to maintain a
hardcoded list of unprotected paths and path prefixes and we will
hopefully reduce the times we encounter the basic auth prompt by web
browsers.
2022-09-01 12:43:32 +02:00
Benedikt Kulmann
6fc87613d5 fix: add index.html to unprotected paths 2022-08-26 10:37:46 +02:00
Benedikt Kulmann
9d67ab3292 fix: set /external path prefix to unprotected 2022-08-25 10:47:46 +02:00
Benedikt Kulmann
9c9a81026c fix: add index.html to unprotected paths in auth middleware 2022-08-25 10:39:55 +02:00
David Christofas
0d2b7e350b add missing unprotected paths 2022-08-24 16:32:25 +02:00
David Christofas
e65eb15f2c add the settings path to the unprotected paths 2022-08-24 11:04:18 +02:00
David Christofas
28a9bf357e end unprotected path prefixes with a slash 2022-08-24 10:12:34 +05:45
David Christofas
6043e019f4 add the fonts path to the unprotected path prefixes 2022-08-24 10:12:34 +05:45
David Christofas
dfe703291f replace strings.Title with cases.Title 2022-08-22 15:26:00 +02:00
David Christofas
12d42e0074 add missing comments 2022-08-22 14:24:12 +02:00
David Christofas
b5ef10dc2b add missing comments and changelog 2022-08-16 16:53:27 +02:00
David Christofas
3f25ca2059 add unprotected path prefix for parallel deployment 2022-08-16 15:45:22 +02:00
David Christofas
905ead629c add unprotected path prefix for external apps 2022-08-16 15:16:48 +02:00
David Christofas
78d85b683d add missing comments 2022-08-16 12:47:44 +02:00
David Christofas
864438b2de add missing unprotected path 2022-08-15 16:04:14 +02:00
David Christofas
3ebfcbff1e add missing unprotected path 2022-08-15 11:38:04 +02:00
David Christofas
5d45f0e856 fix logic of when to add the www-authenticate headers 2022-08-12 10:48:37 +02:00
David Christofas
036c466425 add missing unprotected paths 2022-08-12 10:48:33 +02:00
David Christofas
32f68f91ff add missing www-authentication header on failed authentication 2022-08-12 10:48:29 +02:00
David Christofas
d271ae2451 fix some authentication cases 2022-08-12 10:48:25 +02:00
David Christofas
06ffd9cf8a some more cleaning up 2022-08-12 10:48:21 +02:00
David Christofas
9347657370 remove the oidc tests since they aren't testing anything at the moment
I admit it would be better to implement the tests but I tried and it is a bit tricky since we can't mock everything we would need to mock. I'll wan to get these changes in first and later in the near future we should revisit the auth middleware architecture and refactor it a bit more to be more testable and future proof.
2022-08-12 10:48:17 +02:00
David Christofas
17a4e65f08 add tests for the public share auth middleware 2022-08-12 10:48:13 +02:00
David Christofas
7bc1305cb4 add tests for the basic auth middleware 2022-08-12 10:48:09 +02:00
David Christofas
ef020920e8 update authentication tests 2022-08-12 10:48:04 +02:00
David Christofas
ddfc01bff9 refactor unprotected paths check 2022-08-12 10:47:51 +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
6e848c7254 Use mutex for lazy init function
To avoid possible threading issues
2022-08-03 12:00:31 +02:00