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>
This commit is contained in:
Florian SchadeandMartin committed 2023-03-14 15:10:35 +00:00
1 parent da4a69b2f3
commit 64854fa082
14 files changed
+621 -205

No files matched your search

+2 -2
View File
@@ -33,7 +33,7 @@ variables:
description: ""
do_ignore: true
- rawname: MICRO_LOG_LEVEL
path: ocis-pkg/log/log.go:35
path: ocis-pkg/log/log.go:31
foundincode: true
name: MICRO_LOG_LEVEL
type: ""
@@ -41,7 +41,7 @@ variables:
description: ""
do_ignore: false
- rawname: MICRO_LOG_LEVEL
path: ocis-pkg/log/log.go:31
path: ocis-pkg/log/log.go:35
foundincode: true
name: MICRO_LOG_LEVEL
type: ""
@@ -26,7 +26,7 @@ a| [subs=-attributes]
++false ++
a| [subs=-attributes]
The default role assignments the demo users should be setup.
Flag to enable or disable the creation of the demo users.
a| `LDAP_BIND_DN`
@@ -572,7 +572,7 @@ a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++true ++
++false ++
a| [subs=-attributes]
Allow credentials for CORS.See following chapter for more details: *Access-Control-Allow-Credentials* at \https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials.
@@ -591,7 +591,7 @@ a| [subs=-attributes]
++[]string ++
a| [subs=-attributes]
++[Authorization Origin Content-Type Accept X-Requested-With] ++
++[] ++
a| [subs=-attributes]
A comma-separated list of allowed CORS headers. See following chapter for more details: *Access-Control-Request-Headers* at \https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers.
@@ -610,7 +610,7 @@ a| [subs=-attributes]
++[]string ++
a| [subs=-attributes]
++[GET POST PUT PATCH DELETE OPTIONS] ++
++[] ++
a| [subs=-attributes]
A comma-separated list of allowed CORS methods. See following chapter for more details: *Access-Control-Request-Method* at \https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method
@@ -657,6 +657,7 @@ a| [subs=attributes+]
* xref:{s-path}/graph.adoc[graph] +
* xref:{s-path}/nats.adoc[nats] +
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/search.adoc[search] +
* xref:{s-path}/sharing.adoc[sharing] +
@@ -686,6 +687,7 @@ a| [subs=attributes+]
* xref:{s-path}/groups.adoc[groups] +
* xref:{s-path}/idp.adoc[idp] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
* xref:{s-path}/sharing.adoc[sharing] +
@@ -718,6 +720,7 @@ a| [subs=attributes+]
* xref:{s-path}/groups.adoc[groups] +
* xref:{s-path}/idp.adoc[idp] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
* xref:{s-path}/sharing.adoc[sharing] +
@@ -811,6 +814,7 @@ a| [subs=attributes+]
* xref:{s-path}/nats.adoc[nats] +
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
@@ -828,7 +832,7 @@ a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Allow insecure connections to the frontend.
Whether the NATS server should skip the client certificate verification during the TLS handshake.
a| `OCIS_JWT_SECRET`
@@ -844,6 +848,7 @@ a| [subs=attributes+]
* xref:{s-path}/groups.adoc[groups] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/ocs.adoc[ocs] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/settings.adoc[settings] +
* xref:{s-path}/sharing.adoc[sharing] +
@@ -862,7 +867,7 @@ a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The secret to mint and validate jwt tokens.
The secret to mint and validate JWT tokens.
a| `OCIS_LOG_COLOR`
@@ -884,6 +889,7 @@ a| [subs=attributes+]
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/ocs.adoc[ocs] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
@@ -930,6 +936,7 @@ a| [subs=attributes+]
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/ocs.adoc[ocs] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
@@ -976,6 +983,7 @@ a| [subs=attributes+]
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/ocs.adoc[ocs] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
@@ -1022,6 +1030,7 @@ a| [subs=attributes+]
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/ocs.adoc[ocs] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/postprocessing.adoc[postprocessing] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
@@ -1056,6 +1065,7 @@ a| [subs=attributes+]
* xref:{s-path}/idp.adoc[idp] +
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
* xref:{s-path}/userlog.adoc[userlog] +
@@ -1067,7 +1077,7 @@ a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The machine auth API key used to validate internal requests necessary to access resources from other services.
Machine auth API key used to validate internal requests necessary to access resources from other services.
a| `OCIS_OIDC_ISSUER`
@@ -1103,7 +1113,7 @@ a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Set this to true if you want to enforce passwords on Uploader, Editor or Contributor shares.
Set this to true if you want to enforce passwords on Uploader, Editor or Contributor shares. If not using the global OCIS_SHARING_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD, you must define the FRONTEND_OCS_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD in the frontend service.
a| `OCIS_SPACES_MAX_QUOTA`
@@ -1118,7 +1128,7 @@ a| [subs=-attributes]
++0 ++
a| [subs=-attributes]
Set the global max quota value in bytes. A value of 0 equals unlimited. The value is provided via capabilities.
Set a global max quota for spaces in bytes. A value of 0 equals unlimited. If not using the global OCIS_SPACES_MAX_QUOTA, you must define the FRONTEND_MAX_QUOTA in the frontend service.
a| `OCIS_SYSTEM_USER_API_KEY`
@@ -1365,7 +1375,7 @@ a| [subs=-attributes]
++https://localhost:9200 ++
a| [subs=-attributes]
The public facing URL of the oCIS frontend.
The public facing URL of the oCIS Web UI, used e.g. when sending notification eMails
a| `REVA_GATEWAY`
@@ -1382,6 +1392,7 @@ a| [subs=attributes+]
* xref:{s-path}/idp.adoc[idp] +
* xref:{s-path}/notifications.adoc[notifications] +
* xref:{s-path}/ocdav.adoc[ocdav] +
* xref:{s-path}/policies.adoc[policies] +
* xref:{s-path}/proxy.adoc[proxy] +
* xref:{s-path}/search.adoc[search] +
* xref:{s-path}/sharing.adoc[sharing] +
@@ -1401,7 +1412,7 @@ a| [subs=-attributes]
++127.0.0.1:9142 ++
a| [subs=-attributes]
The CS3 gateway endpoint.
CS3 gateway used to look up user metadata
a| `STORAGE_TRANSFER_SECRET`
@@ -0,0 +1,226 @@
// set the attribute to true or leave empty, true without any quotes.
:show-deprecation: false
ifeval::[{show-deprecation} == true]
[[deprecation-note]]
[caption=]
.Deprecation notes for the policies service
[width="100%",cols="~,~,~,~",options="header"]
|===
| Deprecation Info
| Deprecation Version
| Removal Version
| Deprecation Replacment
|===
endif::[]
[caption=]
.Environment variables for the policies service
[width="100%",cols="~,~,~,~",options="header"]
|===
| Name
| Type
| Default Value
| Description
a|`POLICIES_GRPC_ADDR` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++127.0.0.1:9125 ++
a| [subs=-attributes]
The bind address of the GRPC service.
a|`POLICIES_DEBUG_ADDR` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++127.0.0.1:9129 ++
a| [subs=-attributes]
Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed.
a|`POLICIES_DEBUG_TOKEN` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Token to secure the metrics endpoint.
a|`POLICIES_DEBUG_PPROF` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Enables pprof, which can be used for profiling.
a|`POLICIES_DEBUG_ZPAGES` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Enables zpages, which can be used for collecting and viewing in-memory traces.
a|`OCIS_JWT_SECRET` +
`POLICIES_JWT_SECRET` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The secret to mint and validate jwt tokens.
a|`POLICIES_EVENTS_ENDPOINT` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++127.0.0.1:9233 ++
a| [subs=-attributes]
The address of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture.
a|`POLICIES_EVENTS_CLUSTER` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ocis-cluster ++
a| [subs=-attributes]
The clusterID of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture. Mandatory when using NATS as event system.
a|`OCIS_INSECURE` +
`POLICIES_EVENTS_TLS_INSECURE` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Whether the server should skip the client certificate verification during the TLS handshake.
a|`POLICIES_EVENTS_TLS_ROOT_CA_CERTIFICATE` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The root CA certificate used to validate the server's TLS certificate. If provided POLICIES_EVENTS_TLS_INSECURE will be seen as false.
a|`OCIS_EVENTS_ENABLE_TLS` +
`POLICIES_EVENTS_ENABLE_TLS` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Enable TLS for the connection to the events broker. The events broker is the ocis service which receives and delivers events between the services.
a|`REVA_GATEWAY` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++127.0.0.1:9142 ++
a| [subs=-attributes]
The CS3 gateway endpoint.
a|`OCIS_GRPC_CLIENT_TLS_MODE` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
TLS mode for grpc connection to the go-micro based grpc services. Possible values are 'off', 'insecure' and 'on'. 'off': disables transport security for the clients. 'insecure' allows to use transport security, but disables certificate verification (to be used with the autogenerated self-signed certificates). 'on' enables transport security, including server ceritificate verification.
a|`OCIS_GRPC_CLIENT_TLS_CACERT` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the go-micro based grpc services.
a|`OCIS_MACHINE_AUTH_API_KEY` +
`POLICIES_MACHINE_AUTH_API_KEY` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Machine auth API key used to validate internal requests necessary for the access to resources from other services.
a|`OCIS_LOG_LEVEL` +
`POLICIES_LOG_LEVEL` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The log level. Valid values are: "panic", "fatal", "error", "warn", "info", "debug", "trace".
a|`OCIS_LOG_PRETTY` +
`POLICIES_LOG_PRETTY` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Activates pretty log output.
a|`OCIS_LOG_COLOR` +
`POLICIES_LOG_COLOR` +
a| [subs=-attributes]
++bool ++
a| [subs=-attributes]
++false ++
a| [subs=-attributes]
Activates colorized log output.
a|`OCIS_LOG_FILE` +
`POLICIES_LOG_FILE` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
The path to the log file. Activates logging to this file if set.
a|`POLICIES_ENGINE_TIMEOUT` +
a| [subs=-attributes]
++Duration ++
a| [subs=-attributes]
++10s ++
a| [subs=-attributes]
Sets the timeout the rego expression evaluation can take. The timeout can be set as number followed by a unit identifier like ms, s, etc. Rules default to deny if the timeout was reached.
a|`POLICIES_POSTPROCESSING_QUERY` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Defines the 'Complete Rules' variable defined in the rego rule set this step uses for its evaluation. Defaults to deny if the variable was not found.
|===
@@ -0,0 +1,2 @@
:show-deprecation: false
@@ -125,7 +125,7 @@ a| [subs=-attributes]
a| [subs=-attributes]
++[] ++
a| [subs=-attributes]
A comma separated list of postprocessing steps, processed in order of their appearance. Currently supported values by the system are: 'virusscan' and 'delay'. Custom steps are allowed. See the documentation for instructions.
A comma separated list of postprocessing steps, processed in order of their appearance. Currently supported values by the system are: 'virusscan', 'policies' and 'delay'. Custom steps are allowed. See the documentation for instructions.
a|`POSTPROCESSING_VIRUSSCAN` +
xref:deprecation-note[Deprecation Note]
@@ -398,5 +398,14 @@ a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Path/File for the root CA certificate used to validate the server’s TLS certificate for https enabled backend services.
a|`PROXY_POLICIES_QUERY` +
a| [subs=-attributes]
++string ++
a| [subs=-attributes]
++ ++
a| [subs=-attributes]
Defines the 'Complete Rules' variable defined in the rego rule set this step uses for its evaluation. Rules default to deny if the variable was not found.
|===
@@ -0,0 +1,36 @@
# Autogenerated
# Filename: policies-config-example.yaml
grpc:
addr: 127.0.0.1:9125
tls: null
debug:
addr: 127.0.0.1:9129
token: ""
pprof: false
zpages: false
token_manager:
jwt_secret: ""
events:
endpoint: 127.0.0.1:9233
cluster: ocis-cluster
tls_insecure: false
tls_root_ca_certificate: ""
enable_tls: false
reva:
address: 127.0.0.1:9142
tls:
mode: ""
cacert: ""
grpc_client_tls: null
machine_auth_api_key: ""
log:
level: ""
pretty: false
color: false
file: ""
engine:
timeout: 10s
policies: []
postprocessing:
query: ""
@@ -0,0 +1,25 @@
## Environment Variables
| Name | Type | Default Value | Description |
|------|------|---------------|-------------|
| POLICIES_GRPC_ADDR | string | 127.0.0.1:9125 | The bind address of the GRPC service.|
| POLICIES_DEBUG_ADDR | string | 127.0.0.1:9129 | Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed.|
| POLICIES_DEBUG_TOKEN | string | | Token to secure the metrics endpoint.|
| POLICIES_DEBUG_PPROF | bool | false | Enables pprof, which can be used for profiling.|
| POLICIES_DEBUG_ZPAGES | bool | false | Enables zpages, which can be used for collecting and viewing in-memory traces.|
| OCIS_JWT_SECRET<br/>POLICIES_JWT_SECRET | string | | The secret to mint and validate jwt tokens.|
| POLICIES_EVENTS_ENDPOINT | string | 127.0.0.1:9233 | The address of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture.|
| POLICIES_EVENTS_CLUSTER | string | ocis-cluster | The clusterID of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture. Mandatory when using NATS as event system.|
| OCIS_INSECURE<br/>POLICIES_EVENTS_TLS_INSECURE | bool | false | Whether the server should skip the client certificate verification during the TLS handshake.|
| POLICIES_EVENTS_TLS_ROOT_CA_CERTIFICATE | string | | The root CA certificate used to validate the server's TLS certificate. If provided POLICIES_EVENTS_TLS_INSECURE will be seen as false.|
| OCIS_EVENTS_ENABLE_TLS<br/>POLICIES_EVENTS_ENABLE_TLS | bool | false | Enable TLS for the connection to the events broker. The events broker is the ocis service which receives and delivers events between the services.|
| REVA_GATEWAY | string | 127.0.0.1:9142 | The CS3 gateway endpoint.|
| OCIS_GRPC_CLIENT_TLS_MODE | string | | TLS mode for grpc connection to the go-micro based grpc services. Possible values are 'off', 'insecure' and 'on'. 'off': disables transport security for the clients. 'insecure' allows to use transport security, but disables certificate verification (to be used with the autogenerated self-signed certificates). 'on' enables transport security, including server ceritificate verification.|
| OCIS_GRPC_CLIENT_TLS_CACERT | string | | Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the go-micro based grpc services.|
| OCIS_MACHINE_AUTH_API_KEY<br/>POLICIES_MACHINE_AUTH_API_KEY | string | | Machine auth API key used to validate internal requests necessary for the access to resources from other services.|
| OCIS_LOG_LEVEL<br/>POLICIES_LOG_LEVEL | string | | The log level. Valid values are: "panic", "fatal", "error", "warn", "info", "debug", "trace".|
| OCIS_LOG_PRETTY<br/>POLICIES_LOG_PRETTY | bool | false | Activates pretty log output.|
| OCIS_LOG_COLOR<br/>POLICIES_LOG_COLOR | bool | false | Activates colorized log output.|
| OCIS_LOG_FILE<br/>POLICIES_LOG_FILE | string | | The path to the log file. Activates logging to this file if set.|
| POLICIES_ENGINE_TIMEOUT | Duration | 10s | Sets the timeout the rego expression evaluation can take. The timeout can be set as number followed by a unit identifier like ms, s, etc. Rules default to deny if the timeout was reached.|
| POLICIES_POSTPROCESSING_QUERY | string | | Defines the 'Complete Rules' variable defined in the rego rule set this step uses for its evaluation. Defaults to deny if the variable was not found.|
@@ -11,6 +11,6 @@
| OCIS_INSECURE<br/>POSTPROCESSING_EVENTS_TLS_INSECURE | bool | false | Whether the ocis server should skip the client certificate verification during the TLS handshake.|
| POSTPROCESSING_EVENTS_TLS_ROOT_CA_CERTIFICATE | string | | The root CA certificate used to validate the server's TLS certificate. If provided POSTPROCESSING_EVENTS_TLS_INSECURE will be seen as false.|
| OCIS_EVENTS_ENABLE_TLS<br/>POSTPROCESSING_EVENTS_ENABLE_TLS | bool | false | Enable TLS for the connection to the events broker. The events broker is the ocis service which receives and delivers events between the services.|
| POSTPROCESSING_STEPS | []string | [] | A comma separated list of postprocessing steps, processed in order of their appearance. Currently supported values by the system are: 'virusscan' and 'delay'. Custom steps are allowed. See the documentation for instructions.|
| POSTPROCESSING_STEPS | []string | [] | A comma separated list of postprocessing steps, processed in order of their appearance. Currently supported values by the system are: 'virusscan', 'policies' and 'delay'. Custom steps are allowed. See the documentation for instructions.|
| POSTPROCESSING_VIRUSSCAN | bool | false | After uploading a file but before making it available for download, virus scanning the file can be enabled. Needs as prerequisite the antivirus service to be enabled and configured.|
| POSTPROCESSING_DELAY | Duration | 0s | After uploading a file but before making it available for download, a delay step can be added. Intended for developing purposes only. The duration can be set as number followed by a unit identifier like s, m or h. If a duration is set but the keyword 'delay' is not explicitely added to 'POSTPROCESSING_STEPS', the delay step will be processed as last step. In such a case, a log entry will be written on service startup to remind the admin about that situation.|
@@ -142,3 +142,5 @@ insecure_backends: false
backend_https_cacert: ""
auth_middleware:
credentials_by_user_agent: {}
policies_middleware:
query: ""
@@ -41,4 +41,5 @@
| PROXY_AUTOPROVISION_ACCOUNTS | bool | false | Set this to 'true' to automatically provision users that do not yet exist in the users service on-demand upon first sign-in. To use this a write-enabled libregraph user backend needs to be setup an running.|
| PROXY_ENABLE_BASIC_AUTH | bool | false | Set this to true to enable 'basic authentication' (username/password).|
| PROXY_INSECURE_BACKENDS | bool | false | Disable TLS certificate validation for all HTTP backend connections.|
| PROXY_HTTPS_CACERT | string | | Path/File for the root CA certificate used to validate the server’s TLS certificate for https enabled backend services.|
| PROXY_HTTPS_CACERT | string | | Path/File for the root CA certificate used to validate the server’s TLS certificate for https enabled backend services.|
| PROXY_POLICIES_QUERY | string | | Defines the 'Complete Rules' variable defined in the rego rule set this step uses for its evaluation. Rules default to deny if the variable was not found.|
+89
View File
@@ -0,0 +1,89 @@
---
title: Policies
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/services/policies
geekdocFilePath: _index.md
geekdocCollapseSection: true
---
## Abstract
The policies service provides a new grpc api which can be used to return whether a requested operation is allowed or not. To do so, Open Policy Agent (OPA) is used to determine the set of rules of what is permitted and what is not.
## Table of Contents
{{< toc-tree >}}
## Rego
Policies are written in the [rego query language](https://www.openpolicyagent.org/docs/latest/policy-language/). The location of the rego files can be configured via yaml, a configuration via environment variables is not possible.
The Policies Service consists of the following modules:
* Proxy Authorization (middleware)
* Event Authorization (async post-processing)
* GRPC API (can be used from other services)
To configure the Policies Service, three environment variables need to be defined:
* `POLICIES_ENGINE_TIMEOUT`
* `POLICIES_POSTPROCESSING_QUERY`
* `PROXY_POLICIES_QUERY`
Note that each query setting defines the [Complete Rules](https://www.openpolicyagent.org/docs/latest/#complete-rules) variable defined in the rego rule set the corresponding step uses for the evaluation. If the variable is mistyped or not found, the evaluation defaults to deny. Individual query definitions can be defined for each module.
To activate a the policies service for a module, it must be started with a yaml configuration that points to one or more rego files. Note that if the service is scaled horizontally, each instance should have access to the same rego files to avoid unpredictable results. If a file path has been configured but the file it is not present or accessible, the evaluation defaults to deny.
When using async post-processing which is done via the postprocessing service, the value `policies` must be added to the `POSTPROCESSING_STEPS` configuration in postprocessing service in the order where the evaluation should take place.
## Modules
### GRPC Service
This service can be used from any other internal service. It can also be used for example by third parties to find out if an action is allowed or not. This layer is already used by the proxy middleware.
### Event Service
This layer is event-based and part of the postprocessing service. Since processing at this point is asynchronous, the operations can also take longer and be more expensive, like evaluating the bytes of a file.
### Proxy Middleware
The [ocis proxy](../proxy) already includes such a middleware which uses the [GRPC service](#grpc-service) to evaluate the policies by using a configurable query. Since the Proxy is in heavy use and every request is processed here, only simple and quick decisions should be evaluated. More complex queries such as file evaluation are strongly discouraged.
## Example Policies
The policies service contains a set of pre-configured example policies. Those policies can be found in the [examples directory](https://github.com/owncloud/ocis/tree/master/deployments/examples/service_policies/policies). The contained policies disallows ocis to create certain filetypes, both for the proxy middleware and the events service.
To use the example policies, it's required to configure ocis to use these files which can be done by adding:
```yaml
policies:
engine:
policies:
- YOUR_PATH/examples/policies/proxy.rego
- YOUR_PATH/examples/policies/postprocessing.rego
- YOUR_PATH/examples/policies/utils.rego
```
Once the policies are configured correctly, the _QUERY configuration needs to be defined for the proxy middleware and for the events service.
### Proxy
```yaml
proxy:
policies_middleware:
query: data.proxy.granted
```
The same can be achieved by setting the `PROXY_POLICIES_QUERY=data.proxy.granted` environment variable.
### ASYNC Postprocessing
```yaml
policies:
postprocessing:
query: data.postprocessing.granted
```
The same can be achieved by setting the `POLICIES_POSTPROCESSING_QUERY=data.postprocessing.granted` environment variable. As soon as that query is configured correctly, postprocessing must be informed to use the policies step by setting the environment variable `POSTPROCESSING_STEPS=policies`. Note that additional steps can be configured and their appearance defines the order of processing. For details see the postprocessing service documentation.
@@ -0,0 +1,15 @@
---
title: Service Configuration
date: 2018-05-02T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/services/policies
geekdocFilePath: configuration.md
geekdocCollapseSection: true
---
## Example YAML Config
{{< include file="services/_includes/policies-config-example.yaml" language="yaml" >}}
{{< include file="services/_includes/policies_configvars.md" >}}
+189 -189
View File
@@ -21,193 +21,193 @@ We also suggest to use the last port in your extensions' range as a debug/metric
## Allocations
| Port range | Service |
| ---------- | ----------------------------------------------------------------------------- |
| 9000-9010 | [reserved for Infinite Scale]({{< ref "../../../ocis/_index.md" >}}) |
| 9100-9104 | [web]({{< ref "./web/_index.md" >}}) |
| 9105-9109 | [hello](https://github.com/owncloud/ocis-hello) |
| 9110-9114 | [ocs]({{< ref "./ocs/_index.md" >}}) |
| 9115-9119 | [webdav]({{< ref "./webdav/_index.md" >}}) |
| 9120-9124 | [graph]({{< ref "./graph/_index.md" >}}) |
| 9125-9129 | FREE (formerly used by glauth) |
| 9130-9134 | [idp]({{< ref "./idp/_index.md" >}}) |
| 9135-9139 | FREE (formerly used by graph-explorer) |
| 9140-9141 | [frontend]({{< ref "./frontend/_index.md" >}}) |
| 9142-9143 | [gateway]({{< ref "./gateway/_index.md" >}}) |
| 9144-9145 | [users]({{< ref "./users/_index.md" >}}) |
| 9146-9147 | [auth-basic]({{< ref "./auth-basic/_index.md" >}}) |
| 9148-9149 | [auth-bearer]({{< ref "./auth-bearer/_index.md" >}}) |
| 9150-9153 | [sharing]({{< ref "./sharing/_index.md" >}}) |
| 9154-9156 | [storage-shares]({{< ref "./storage-shares/_index.md" >}}) |
| 9157-9159 | [storage-users]({{< ref "./storage-users/_index.md" >}}) |
| 9160-9162 | [groups]({{< ref "./groups/_index.md" >}}) |
| 9163 | [ocdav]({{< ref "./ocdav/_index.md" >}}) |
| 9164 | [groups]({{< ref "./groups/_index.md" >}}) |
| 9165 | [app-provider]({{< ref "./app-provider/_index.md" >}}) |
| 9166-9169 | [auth-machine]({{< ref "./auth-machine/_index.md" >}}) |
| 9170-9174 | [notifications]({{< ref "./notifications/_index.md" >}}) |
| 9175-9179 | [storage-publiclink]({{< ref "./storage-publiclink/_index.md" >}}) |
| 9180-9184 | FREE (formerly used by accounts) |
| 9185-9189 | [thumbnails]({{< ref "./thumbnails/_index.md" >}}) |
| 9190-9194 | [settings]({{< ref "./settings/_index.md" >}}) |
| 9195-9199 | FREE |
| 9200-9204 | [proxy]({{< ref "./proxy/_index.md" >}}) |
| 9205-9209 | [proxy]({{< ref "./proxy/_index.md" >}}) |
| 9210-9214 | FREE |
| 9215-9219 | [storage-system]({{< ref "./storage-system/_index.md" >}}) |
| 9220-9224 | [search]({{< ref "./search/_index.md" >}}) |
| 9225-9229 | FREE |
| 9230-9234 | [nats]({{< ref "./nats/_index.md" >}}) |
| 9235-9239 | [idm]({{< ref "./idm/_index.md" >}}) |
| 9240-9244 | [app-registry]({{< ref "./app-registry/_index.md" >}}) |
| 9245-9249 | FREE |
| Port range | Service |
|------------|----------------------------------------------------------------------------------------|
| 9000-9010 | [reserved for Infinite Scale]({{< ref "../../../ocis/_index.md" >}}) |
| 9100-9104 | [web]({{< ref "./web/_index.md" >}}) |
| 9105-9109 | [hello](https://github.com/owncloud/ocis-hello) |
| 9110-9114 | [ocs]({{< ref "./ocs/_index.md" >}}) |
| 9115-9119 | [webdav]({{< ref "./webdav/_index.md" >}}) |
| 9120-9124 | [graph]({{< ref "./graph/_index.md" >}}) |
| 9125-9129 | [policies]({{< ref "./policies/_index.md" >}}) |
| 9130-9134 | [idp]({{< ref "./idp/_index.md" >}}) |
| 9135-9139 | FREE (formerly used by graph-explorer) |
| 9140-9141 | [frontend]({{< ref "./frontend/_index.md" >}}) |
| 9142-9143 | [gateway]({{< ref "./gateway/_index.md" >}}) |
| 9144-9145 | [users]({{< ref "./users/_index.md" >}}) |
| 9146-9147 | [auth-basic]({{< ref "./auth-basic/_index.md" >}}) |
| 9148-9149 | [auth-bearer]({{< ref "./auth-bearer/_index.md" >}}) |
| 9150-9153 | [sharing]({{< ref "./sharing/_index.md" >}}) |
| 9154-9156 | [storage-shares]({{< ref "./storage-shares/_index.md" >}}) |
| 9157-9159 | [storage-users]({{< ref "./storage-users/_index.md" >}}) |
| 9160-9162 | [groups]({{< ref "./groups/_index.md" >}}) |
| 9163 | [ocdav]({{< ref "./ocdav/_index.md" >}}) |
| 9164 | [groups]({{< ref "./groups/_index.md" >}}) |
| 9165 | [app-provider]({{< ref "./app-provider/_index.md" >}}) |
| 9166-9169 | [auth-machine]({{< ref "./auth-machine/_index.md" >}}) |
| 9170-9174 | [notifications]({{< ref "./notifications/_index.md" >}}) |
| 9175-9179 | [storage-publiclink]({{< ref "./storage-publiclink/_index.md" >}}) |
| 9180-9184 | FREE (formerly used by accounts) |
| 9185-9189 | [thumbnails]({{< ref "./thumbnails/_index.md" >}}) |
| 9190-9194 | [settings]({{< ref "./settings/_index.md" >}}) |
| 9195-9199 | FREE |
| 9200-9204 | [proxy]({{< ref "./proxy/_index.md" >}}) |
| 9205-9209 | [proxy]({{< ref "./proxy/_index.md" >}}) |
| 9210-9214 | FREE |
| 9215-9219 | [storage-system]({{< ref "./storage-system/_index.md" >}}) |
| 9220-9224 | [search]({{< ref "./search/_index.md" >}}) |
| 9225-9229 | FREE |
| 9230-9234 | [nats]({{< ref "./nats/_index.md" >}}) |
| 9235-9239 | [idm]({{< ref "./idm/_index.md" >}}) |
| 9240-9244 | [app-registry]({{< ref "./app-registry/_index.md" >}}) |
| 9245-9249 | FREE |
| 9250-9254 | [ocis server (runtime)](https://github.com/owncloud/ocis/tree/master/ocis/pkg/runtime) |
| 9255-9259 | FREE |
| 9260-9264 | FREE |
| 9265-9269 | FREE |
| 9270-9274 | FREE |
| 9275-9279 | FREE |
| 9280-9284 | FREE |
| 9285-9289 | FREE |
| 9290-9294 | FREE |
| 9295-9299 | FREE |
| 9300-9304 | FREE |
| 9305-9309 | FREE |
| 9310-9314 | FREE |
| 9315-9319 | FREE |
| 9320-9324 | FREE |
| 9325-9329 | FREE |
| 9330-9334 | FREE |
| 9335-9339 | FREE |
| 9340-9344 | FREE |
| 9345-9349 | FREE |
| 9350-9354 | FREE |
| 9355-9359 | FREE |
| 9360-9364 | FREE |
| 9365-9369 | FREE |
| 9370-9374 | FREE |
| 9375-9379 | FREE |
| 9380-9384 | FREE |
| 9385-9389 | FREE |
| 9390-9394 | FREE |
| 9395-9399 | FREE |
| 9400-9404 | FREE |
| 9405-9409 | FREE |
| 9410-9414 | FREE |
| 9415-9419 | FREE |
| 9420-9424 | FREE |
| 9425-9429 | FREE |
| 9430-9434 | FREE |
| 9435-9439 | FREE |
| 9440-9444 | FREE |
| 9445-9449 | FREE |
| 9450-9454 | FREE |
| 9455-9459 | FREE |
| 9460-9464 | [store]({{< ref "./store/_index.md" >}}) |
| 9465-9469 | FREE |
| 9470-9474 | FREE |
| 9475-9479 | FREE |
| 9480-9484 | FREE |
| 9485-9489 | FREE |
| 9490-9494 | FREE |
| 9495-9499 | FREE |
| 9500-9504 | FREE |
| 9505-9509 | FREE |
| 9510-9514 | FREE |
| 9515-9519 | FREE |
| 9520-9524 | FREE |
| 9525-9529 | FREE |
| 9530-9534 | FREE |
| 9535-9539 | FREE |
| 9540-9544 | FREE |
| 9545-9549 | FREE |
| 9550-9554 | FREE |
| 9555-9559 | FREE |
| 9560-9564 | FREE |
| 9565-9569 | FREE |
| 9570-9574 | FREE |
| 9575-9579 | FREE |
| 9580-9584 | FREE |
| 9585-9589 | FREE |
| 9590-9594 | FREE |
| 9595-9599 | FREE |
| 9600-9604 | FREE |
| 9605-9609 | FREE |
| 9610-9614 | FREE |
| 9615-9619 | FREE |
| 9620-9624 | FREE |
| 9625-9629 | FREE |
| 9630-9634 | FREE |
| 9635-9639 | FREE |
| 9640-9644 | FREE |
| 9645-9649 | FREE |
| 9650-9654 | FREE |
| 9655-9659 | FREE |
| 9660-9664 | FREE |
| 9665-9669 | FREE |
| 9670-9674 | FREE |
| 9675-9679 | FREE |
| 9680-9684 | FREE |
| 9685-9689 | FREE |
| 9690-9694 | FREE |
| 9695-9699 | FREE |
| 9700-9704 | FREE |
| 9705-9709 | FREE |
| 9710-9714 | FREE |
| 9715-9719 | FREE |
| 9720-9724 | FREE |
| 9725-9729 | FREE |
| 9730-9734 | FREE |
| 9735-9739 | FREE |
| 9740-9744 | FREE |
| 9745-9749 | FREE |
| 9750-9754 | FREE |
| 9755-9759 | FREE |
| 9760-9764 | FREE |
| 9765-9769 | FREE |
| 9770-9774 | FREE |
| 9775-9779 | FREE |
| 9780-9784 | FREE |
| 9785-9789 | FREE |
| 9790-9794 | FREE |
| 9795-9799 | FREE |
| 9800-9804 | FREE |
| 9805-9809 | FREE |
| 9810-9814 | FREE |
| 9815-9819 | FREE |
| 9820-9824 | FREE |
| 9825-9829 | FREE |
| 9830-9834 | FREE |
| 9835-9839 | FREE |
| 9840-9844 | FREE |
| 9845-9849 | FREE |
| 9850-9854 | FREE |
| 9855-9859 | FREE |
| 9860-9864 | FREE |
| 9865-9869 | FREE |
| 9870-9874 | FREE |
| 9875-9879 | FREE |
| 9880-9884 | FREE |
| 9885-9889 | FREE |
| 9890-9894 | FREE |
| 9895-9899 | FREE |
| 9900-9904 | FREE |
| 9905-9909 | FREE |
| 9910-9914 | FREE |
| 9915-9919 | FREE |
| 9920-9924 | FREE |
| 9925-9929 | FREE |
| 9930-9934 | FREE |
| 9935-9939 | FREE |
| 9940-9944 | FREE |
| 9945-9949 | FREE |
| 9950-9954 | FREE |
| 9955-9959 | FREE |
| 9960-9964 | FREE |
| 9965-9969 | FREE |
| 9970-9974 | FREE |
| 9975-9979 | FREE |
| 9980-9984 | FREE |
| 9985-9989 | FREE |
| 9990-9994 | FREE |
| 9995-9999 | FREE |
| 9255-9259 | FREE |
| 9260-9264 | FREE |
| 9265-9269 | FREE |
| 9270-9274 | FREE |
| 9275-9279 | FREE |
| 9280-9284 | FREE |
| 9285-9289 | FREE |
| 9290-9294 | FREE |
| 9295-9299 | FREE |
| 9300-9304 | FREE |
| 9305-9309 | FREE |
| 9310-9314 | FREE |
| 9315-9319 | FREE |
| 9320-9324 | FREE |
| 9325-9329 | FREE |
| 9330-9334 | FREE |
| 9335-9339 | FREE |
| 9340-9344 | FREE |
| 9345-9349 | FREE |
| 9350-9354 | FREE |
| 9355-9359 | FREE |
| 9360-9364 | FREE |
| 9365-9369 | FREE |
| 9370-9374 | FREE |
| 9375-9379 | FREE |
| 9380-9384 | FREE |
| 9385-9389 | FREE |
| 9390-9394 | FREE |
| 9395-9399 | FREE |
| 9400-9404 | FREE |
| 9405-9409 | FREE |
| 9410-9414 | FREE |
| 9415-9419 | FREE |
| 9420-9424 | FREE |
| 9425-9429 | FREE |
| 9430-9434 | FREE |
| 9435-9439 | FREE |
| 9440-9444 | FREE |
| 9445-9449 | FREE |
| 9450-9454 | FREE |
| 9455-9459 | FREE |
| 9460-9464 | [store]({{< ref "./store/_index.md" >}}) |
| 9465-9469 | FREE |
| 9470-9474 | FREE |
| 9475-9479 | FREE |
| 9480-9484 | FREE |
| 9485-9489 | FREE |
| 9490-9494 | FREE |
| 9495-9499 | FREE |
| 9500-9504 | FREE |
| 9505-9509 | FREE |
| 9510-9514 | FREE |
| 9515-9519 | FREE |
| 9520-9524 | FREE |
| 9525-9529 | FREE |
| 9530-9534 | FREE |
| 9535-9539 | FREE |
| 9540-9544 | FREE |
| 9545-9549 | FREE |
| 9550-9554 | FREE |
| 9555-9559 | FREE |
| 9560-9564 | FREE |
| 9565-9569 | FREE |
| 9570-9574 | FREE |
| 9575-9579 | FREE |
| 9580-9584 | FREE |
| 9585-9589 | FREE |
| 9590-9594 | FREE |
| 9595-9599 | FREE |
| 9600-9604 | FREE |
| 9605-9609 | FREE |
| 9610-9614 | FREE |
| 9615-9619 | FREE |
| 9620-9624 | FREE |
| 9625-9629 | FREE |
| 9630-9634 | FREE |
| 9635-9639 | FREE |
| 9640-9644 | FREE |
| 9645-9649 | FREE |
| 9650-9654 | FREE |
| 9655-9659 | FREE |
| 9660-9664 | FREE |
| 9665-9669 | FREE |
| 9670-9674 | FREE |
| 9675-9679 | FREE |
| 9680-9684 | FREE |
| 9685-9689 | FREE |
| 9690-9694 | FREE |
| 9695-9699 | FREE |
| 9700-9704 | FREE |
| 9705-9709 | FREE |
| 9710-9714 | FREE |
| 9715-9719 | FREE |
| 9720-9724 | FREE |
| 9725-9729 | FREE |
| 9730-9734 | FREE |
| 9735-9739 | FREE |
| 9740-9744 | FREE |
| 9745-9749 | FREE |
| 9750-9754 | FREE |
| 9755-9759 | FREE |
| 9760-9764 | FREE |
| 9765-9769 | FREE |
| 9770-9774 | FREE |
| 9775-9779 | FREE |
| 9780-9784 | FREE |
| 9785-9789 | FREE |
| 9790-9794 | FREE |
| 9795-9799 | FREE |
| 9800-9804 | FREE |
| 9805-9809 | FREE |
| 9810-9814 | FREE |
| 9815-9819 | FREE |
| 9820-9824 | FREE |
| 9825-9829 | FREE |
| 9830-9834 | FREE |
| 9835-9839 | FREE |
| 9840-9844 | FREE |
| 9845-9849 | FREE |
| 9850-9854 | FREE |
| 9855-9859 | FREE |
| 9860-9864 | FREE |
| 9865-9869 | FREE |
| 9870-9874 | FREE |
| 9875-9879 | FREE |
| 9880-9884 | FREE |
| 9885-9889 | FREE |
| 9890-9894 | FREE |
| 9895-9899 | FREE |
| 9900-9904 | FREE |
| 9905-9909 | FREE |
| 9910-9914 | FREE |
| 9915-9919 | FREE |
| 9920-9924 | FREE |
| 9925-9929 | FREE |
| 9930-9934 | FREE |
| 9935-9939 | FREE |
| 9940-9944 | FREE |
| 9945-9949 | FREE |
| 9950-9954 | FREE |
| 9955-9959 | FREE |
| 9960-9964 | FREE |
| 9965-9969 | FREE |
| 9970-9974 | FREE |
| 9975-9979 | FREE |
| 9980-9984 | FREE |
| 9985-9989 | FREE |
| 9990-9994 | FREE |
| 9995-9999 | FREE |