blob: 9dabb3040a1f46130748fc3f05649b922ce62bef [file] [log] [blame]
Saryu Shahb5ce8852017-11-02 00:56:03 +00001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4*********************************
5Creating and Using Guard Policies
6*********************************
7
8.. contents::
9 :depth: 3
10
11Background
12^^^^^^^^^^
13
14Guard policies are used to limit what operations shall be permitted. These policies are specified in the Policy GUI or restful API and either return "PERMIT" or "DENY" on request.
15
Saryu Shahd14620d2017-11-03 21:02:26 +000016There are 2 types of policies, guard policies and blacklist guard policies. The blacklist describes what is not allowed to be permitted and guard policies describe what is allowed to be permitted. The Policy PDP behaves in a PERMIT overrides fashion, that is, if any policy permits, it will override any denies.
17
18.. note:: *Limit Functionality*: The determination to deny a request because it has exceeded the limit is based on the number of entries in the **database**.
Saryu Shahb5ce8852017-11-02 00:56:03 +000019
20Creating Guard Policies
21^^^^^^^^^^^^^^^^^^^^^^^
22
23There are two options for creating guard policies: (1) through the GUI and (2) through the restful API.
24
25GUI Method
26----------
27
28The GUARD policy can be created from the POLICY GUI as shown below.
29
Saryu Shahb5ce8852017-11-02 00:56:03 +000030.. image:: PolicyGUI_GuardPolicy.png
31
Saryu Shahb5ce8852017-11-02 00:56:03 +000032
33API Method
34----------
35
Saryu Shahd14620d2017-11-03 21:02:26 +000036To create the policy, use the PUT /createPolicy API. This request uses Basic Access Authentication.
37
38The request should be in the following form for the regular guard policy:
Saryu Shahb5ce8852017-11-02 00:56:03 +000039
Saryu Shah73009de2017-11-02 16:59:23 +000040.. code-block:: json
Saryu Shahb5ce8852017-11-02 00:56:03 +000041 :caption: Regular Guard Policy Creation
42 :linenos:
43
44 {
45 "policyClass": "Decision",
46 "policyName": "Test.TestingGUARDapitest",
47 "policyDescription": "Testing new YAML Guard Policy",
48 "onapName": "PDPD",
49 "ruleProvider": "GUARD_YAML",
50 "attributes": {
51 "MATCHING": {
52 "actor": "APPC",
53 "recipe": "restart",
54 "targets" : "test",
55 "clname" : "test",
56 "limit": "5",
57 "timeWindow": "15",
58 "timeUnits" : "minute",
59 "guardActiveStart": "05:00:00-05:00",
60 "guardActiveEnd": "23:59:59-05:00"
61 }
62 }
63 }
64
65The request should be in the following form for blacklist guard policy:
66
Saryu Shah73009de2017-11-02 16:59:23 +000067.. code-block:: json
Saryu Shahb5ce8852017-11-02 00:56:03 +000068 :caption: Blacklist Guard Policy Creation
69 :linenos:
70
71 {
72 "policyClass": "Decision",
73 "policyName": "Test.TestingBLGUARD",
74 "policyDescription": "Testing New BL YAML Guard Policy",
75 "onapName": "MSO",
76 "ruleProvider": "GUARD_BL_YAML",
77 "attributes": {
78 "MATCHING": {
79 "actor": "APPC",
80 "recipe": "restart",
81 "clname": "test",
82 "guardActiveStart": "05:00:00-05:00",
83 "guardActiveEnd": "23:59:59-05:00",
84 "blackList": "target1,target2,target3"
85 }
86 }
87 }
88
89Using Guard Policies
90^^^^^^^^^^^^^^^^^^^^
91
92In order to use the guard policies just make an http request. For example:
93
94.. code-block:: bash
95
96 http
97 POST pdp:8081/pdp/api/getDecision
98 Authorization:<yourAuth> ClientAuth:<yourClientAuth>
99 Environment:<environment> Content-Type:application/json < guard_request.json
100
101| where:
Saryu Shah73009de2017-11-02 16:59:23 +0000102| *<yourAuth>* is the string generated from user:pass converted to base64 encoding.
103| *<yourClientAuth>* is generated the same way but from the client user and pass.
104| *<environment>* is the context of the request. For example: TEST
Saryu Shahb5ce8852017-11-02 00:56:03 +0000105
106The guard_request.json should be in the form of the following:
107
108.. code-block:: json
109 :caption: guard_request.json
110
111 {
112 "decisionAttributes": {
113 "actor": "APPC",
114 "recipe": "Restart",
115 "target": "test13",
116 "clname" : "piptest"
117 },
118 "onapName": "PDPD"
119 }
120
Saryu Shahd14620d2017-11-03 21:02:26 +0000121A response containing a PERMIT or DENY in uppercase is returned as follows:
Saryu Shahb5ce8852017-11-02 00:56:03 +0000122
123.. code-block:: json
124 :caption: Response
125
126 {
127 "decision": "PERMIT",
128 "details": "Decision Permit. OK!"
129 }
130
131
Saryu Shah4300d572017-11-02 13:13:59 +0000132End of Document
Saryu Shahb5ce8852017-11-02 00:56:03 +0000133
Saryu Shah83f3ae32017-11-06 23:18:08 +0000134.. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Creating+and+Using+Guard+Policies
135
136