|
| 1 | += ADRXXX: Authorization decision layer |
| 2 | +Felix Hennig <felix.hennig@stackable.tech> |
| 3 | +v0.1, 2024-01-18 |
| 4 | +:status: draft |
| 5 | + |
| 6 | +* Status: {status} |
| 7 | +* Deciders: TBD |
| 8 | +* Date: 2024-01-18 |
| 9 | +
|
| 10 | +Technical Story: https://github.com/stackabletech/issues/issues/439 |
| 11 | + |
| 12 | +== Problem Statement |
| 13 | + |
| 14 | +The Stackable Data Platform provides the OpenPolicyAgent as a policy engine, but we currently do not supply examples or rule frameworks to the users to easily get started with writing authorization policies. |
| 15 | + |
| 16 | +We want to supply a rego rule library that platform users can use as a default or as a starting point to write their own Rego rules. |
| 17 | +These rules (and accompanying data structures) should expose all the product specifics that each product offers. |
| 18 | +A simplified and abstracted authorization layer will be built later, on top of this one. |
| 19 | + |
| 20 | +== Decision Drivers |
| 21 | + |
| 22 | +Users can already write their own rego rules, but we want to make it easier for them and allow them to only write JSON policies. |
| 23 | +At the same time we still want them to have as much control over the product as possible, without having to write their own Rego rules. |
| 24 | + |
| 25 | +== Proposed design |
| 26 | + |
| 27 | +We have specific rego rules per product. |
| 28 | +These need to be highly specific, because every authorizer has a different request structure. |
| 29 | + |
| 30 | +While there are some commonalities across products (they all have a 'resource' concept), details are product specific and difficult to generalize |
| 31 | +without losing out on fine grained control. |
| 32 | +We want to keep as much control as possible. |
| 33 | + |
| 34 | +The RegoRules are deployed by the product operator as ConfigMaps. |
| 35 | +The package name contains the version of the ruleset, the product and the product version: `stackable.v1.trino.v439` |
| 36 | + |
| 37 | +NOTE: Should we simply version the stackable rules with the platform version? |
| 38 | + |
| 39 | +=== Cluster/Stacklet information in the requests |
| 40 | + |
| 41 | +Resources are already organized hierarchically, for example in Trino: Catalog, Schema, Table. |
| 42 | +The Stacklet sits on top of this, and can be seen as another layer. |
| 43 | +Because of this, it makes sense to add the Stacklet name, namespace and labels to the authorization request. |
| 44 | + |
| 45 | +The information could be added by the specific authorizer plugin, but at least for Kafka and Trino, this would require patching the upstream authorizer. |
| 46 | + |
| 47 | +Alternatively we could add a little intermediate package: |
| 48 | + |
| 49 | +[source] |
| 50 | +---- |
| 51 | +package enrichRequest.simpleTrino # auto generated package name |
| 52 | +
|
| 53 | +import rego.v1 |
| 54 | +import myRules # package name taken from the clusterConfig |
| 55 | +
|
| 56 | +allow if { |
| 57 | + myRules.allow with input as { # package name taken from the clusterConfig |
| 58 | + "product": "trino", |
| 59 | + "cluster": { # the name and labels are taken from the kubernetes metadata |
| 60 | + "name": "simple-trino", |
| 61 | + "namespace": "foo", |
| 62 | + "labels": { |
| 63 | + "dev": true |
| 64 | + } |
| 65 | + }, |
| 66 | + "request": input |
| 67 | + } |
| 68 | +} |
| 69 | +---- |
| 70 | + |
| 71 | +This could be generated by the product operators and would be "invisible" to the user. |
| 72 | + |
| 73 | +=== Using the Stackable Rego Framework |
| 74 | + |
| 75 | +Currently, the user specifies a `package` when using the OPA authorizer. |
| 76 | + |
| 77 | +[source,yaml] |
| 78 | +---- |
| 79 | +kind: TrinoCluster |
| 80 | +metadata: |
| 81 | + name: simple-trino |
| 82 | + labels: |
| 83 | + dev: true |
| 84 | +spec: |
| 85 | + image: |
| 86 | + productVersion: "428" |
| 87 | + clusterConfig: |
| 88 | + authorization: |
| 89 | + opa: |
| 90 | + configMapName: my-opa |
| 91 | + package: myRules |
| 92 | +---- |
| 93 | + |
| 94 | +To make it easy to use the framework, the framework should either be the default (and is maybe versioned with the platform version) |
| 95 | +or you select the version of the rule framework like this: |
| 96 | + |
| 97 | +[source,yaml] |
| 98 | +---- |
| 99 | +kind: TrinoCluster |
| 100 | +metadata: |
| 101 | + name: simple-trino |
| 102 | + labels: |
| 103 | + dev: true |
| 104 | +spec: |
| 105 | + image: |
| 106 | + productVersion: "428" |
| 107 | + clusterConfig: |
| 108 | + authorization: |
| 109 | + opa: |
| 110 | + configMapName: my-opa |
| 111 | + stackableRules: v1 |
| 112 | +---- |
0 commit comments