Initial drop of rProxy code
[aaf/cadi.git] / sidecar / rproxy / README.md
1 # Introduction
2
3 The AAF Reverse Proxy is a proxy microservice which intercepts incoming REST requests by, extracting the credentials from the request and authenticate/authorises
4 with a configured security provider. It is one of two components (along with the Forward proxy) deployed as a Kubernetes sidecar to
5 separate the responsibility of authentication and authorization away from the primary microservice, this service is responsible for
6 controlling access to the REST URL endpoints exposed by the primary microservice, and propogating security credentials to downstream microservices. 
7
8 ## Features
9
10 Reverse Proxy:
11
12 * The service will intercept all incoming REST requests to the primary service, extract and cache the token credentials in the Forward proxy.
13 * Invokes the authentication and authorisation providers to validate the extracted tokens, and retrieve its list of authorisations
14 * Invokes the enforcement point filter to determine whether the incoming request URI and retrieved permissions match the list of granted URIs and permissions
15   configured in the URI authorisation file. If authorisation is successful, forward the request to the primary service.
16
17 ## Configuring the rProxy service
18 The rProxy service is configured through property and json files that resides under the ${CONFIG_HOME} environment variable.
19
20 The files have the following configurable properties:
21
22 ###cadi.properties
23
24 cadi_loglevel log level of the cadi filter, e.g. DEBUG, INFO
25 cadi_keyfile  location to the cadi key file
26 cadi_truststore 
27 cadi_truststore_password
28 aaf_url hostname and port of the server hosting the AAF service, e.g. https://aaf.osaaf.org:30247
29 aaf_env AAF environment type, e.g. DEV, PROD
30 aaf_id aafadmin user, e.g. demo@people.osaaf.org
31 aaf_password aafadmin user password encrypted with the cadi_keyfile, e.g. enc:92w4px0y_rrm265LXLpw58QnNPgDXykyA1YTrflbAKz
32 cadi_x509_issuers colon separated list of client cert issuers
33
34 ###reverse-proxy.properties
35
36 transactionid.header.name       This is the name of the header in incoming requests that will contain the transaction ID.       X-TransactionId
37
38 ###primary-service.properties
39
40 primary-service.protocol http protocol of the primary service e.g. https
41 primary-service.host location of the primary service, since this sidecar resides in the same pod of the primary service. localhost
42 primary-service.port port of the primary service
43
44 ###forward-proxy.properties
45
46 forward-proxy.protocol http protocol of the fproxy service e.g. https
47 forward-proxy.host location of the fproxy service, since this sidecar resides in the same pod of the primary service. localhost
48 forward-proxy.port port of the fproxy service
49 forward-proxy.cacheurl URI to the store credential cache. /credential-cache
50
51 ### auth/uri-authorization.json
52 This file contains the list of required AAF permissions authorised for the request URI, permissions will be tested against the first matching URI.
53 If the user doesn't have those permissions then the next matching URI will be tested until the list of URIs is exhausted.
54 URIs will be matched in order as positioned in the configuration file. Wildcarding is supported as standard regular expression matches for both URIs and permissions.
55
56 [
57     {
58       "uri": "URI 1",
59       "permissions": [
60         "permission 1",
61         "permission 2",
62         "..."]
63     },
64     {
65       "uri": "URI 2",
66       "permissions": [
67         "permission 3",
68         "permission 4",
69         "..."]     
70     }
71 ]
72
73 e.g.
74 [
75     {
76       "uri": "\/aai\/v13\/cloud-infrastructure\/cloud-regions$",
77       "permissions": [
78         "org.onap.osaaf.resources.access|rest|read"
79        ]
80     },
81     {
82       "uri": "\/aai\/v13\/cloud-infrastructure\/cloud-regions\/cloud-region\/[^\/]+[\/][^\/]+$*",
83       "permissions": [
84         "org.onap.osaaf.resources.access|clouds|read",
85         "org.onap.osaaf.auth.resources.access|tenants|read"
86       ]     
87     },
88     {
89       "uri": "\/aai\/v13\/cloud-infrastructure\/cloud-regions\/cloud-region\/[^\/]+[\/][^\/]+\/tenants/tenant/[^\/]+/vservers/vserver/[^\/]+$",
90       "permissions": [
91         "org.onap.osaaf.auth.resources.access|clouds|read",
92         "org.onap.osaaf.auth.resources.access|tenants|read",
93         "org.onap.osaaf.auth.resources.access|vservers|read"
94       ]     
95     }
96 ]