Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. http://creativecommons.org/licenses/by/4.0 |
| 3 | |
| 4 | ********************************* |
| 5 | Creating and Using Guard Policies |
| 6 | ********************************* |
| 7 | |
| 8 | .. contents:: |
| 9 | :depth: 3 |
| 10 | |
| 11 | Background |
| 12 | ^^^^^^^^^^ |
| 13 | |
| 14 | Guard 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 Shah | d14620d | 2017-11-03 21:02:26 +0000 | [diff] [blame] | 16 | There 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 Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 19 | |
| 20 | Creating Guard Policies |
| 21 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 22 | |
| 23 | There are two options for creating guard policies: (1) through the GUI and (2) through the restful API. |
| 24 | |
| 25 | GUI Method |
| 26 | ---------- |
| 27 | |
| 28 | The GUARD policy can be created from the POLICY GUI as shown below. |
| 29 | |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 30 | .. image:: PolicyGUI_GuardPolicy.png |
| 31 | |
Saryu Shah | 0935909 | 2018-08-18 01:06:37 +0000 | [diff] [blame] | 32 | In a Blacklist policy, the blacklist entries can be entered either manually or imported from an excel sheet. This import option can also be used to delete existing blacklist entries and to add new entries. |
| 33 | |
| 34 | .. image:: PolicyGUI_BlacklistPolicy.png |
| 35 | |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 36 | |
| 37 | API Method |
| 38 | ---------- |
| 39 | |
Saryu Shah | d14620d | 2017-11-03 21:02:26 +0000 | [diff] [blame] | 40 | To create the policy, use the PUT /createPolicy API. This request uses Basic Access Authentication. |
| 41 | |
| 42 | The request should be in the following form for the regular guard policy: |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 43 | |
Saryu Shah | 73009de | 2017-11-02 16:59:23 +0000 | [diff] [blame] | 44 | .. code-block:: json |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 45 | :caption: Regular Guard Policy Creation |
| 46 | :linenos: |
| 47 | |
| 48 | { |
| 49 | "policyClass": "Decision", |
| 50 | "policyName": "Test.TestingGUARDapitest", |
| 51 | "policyDescription": "Testing new YAML Guard Policy", |
| 52 | "onapName": "PDPD", |
| 53 | "ruleProvider": "GUARD_YAML", |
| 54 | "attributes": { |
| 55 | "MATCHING": { |
| 56 | "actor": "APPC", |
| 57 | "recipe": "restart", |
| 58 | "targets" : "test", |
| 59 | "clname" : "test", |
| 60 | "limit": "5", |
| 61 | "timeWindow": "15", |
| 62 | "timeUnits" : "minute", |
| 63 | "guardActiveStart": "05:00:00-05:00", |
| 64 | "guardActiveEnd": "23:59:59-05:00" |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
Michael Mokry | e957a1d | 2018-09-10 15:23:15 -0500 | [diff] [blame] | 69 | The request should be in the following form for the Min/Max guard policy: |
| 70 | |
| 71 | .. code-block:: json |
| 72 | :caption: Min/Max Guard Policy Creation |
| 73 | :linenos: |
| 74 | |
| 75 | { |
| 76 | "policyClass": "Decision", |
| 77 | "policyName": "Test.TestingGUARDMinMaxtest", |
| 78 | "policyDescription": "Testing new Min/Max Guard Policy", |
| 79 | "onapName": "PDPD", |
| 80 | "ruleProvider": "GUARD_MIN_MAX", |
| 81 | "attributes": { |
| 82 | "MATCHING": { |
| 83 | "actor": "SO", |
| 84 | "recipe": "scaleOut", |
| 85 | "targets" : ".*", |
| 86 | "clname" : "test", |
| 87 | "min": "1", |
| 88 | "max": "5", |
| 89 | "guardActiveStart": "05:00:00-05:00", |
| 90 | "guardActiveEnd": "23:59:59-05:00" |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 95 | The request should be in the following form for blacklist guard policy: |
| 96 | |
Saryu Shah | 73009de | 2017-11-02 16:59:23 +0000 | [diff] [blame] | 97 | .. code-block:: json |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 98 | :caption: Blacklist Guard Policy Creation |
| 99 | :linenos: |
| 100 | |
| 101 | { |
| 102 | "policyClass": "Decision", |
| 103 | "policyName": "Test.TestingBLGUARD", |
| 104 | "policyDescription": "Testing New BL YAML Guard Policy", |
| 105 | "onapName": "MSO", |
| 106 | "ruleProvider": "GUARD_BL_YAML", |
| 107 | "attributes": { |
| 108 | "MATCHING": { |
| 109 | "actor": "APPC", |
| 110 | "recipe": "restart", |
| 111 | "clname": "test", |
| 112 | "guardActiveStart": "05:00:00-05:00", |
| 113 | "guardActiveEnd": "23:59:59-05:00", |
| 114 | "blackList": "target1,target2,target3" |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | Using Guard Policies |
| 120 | ^^^^^^^^^^^^^^^^^^^^ |
| 121 | |
| 122 | In order to use the guard policies just make an http request. For example: |
| 123 | |
| 124 | .. code-block:: bash |
| 125 | |
| 126 | http |
| 127 | POST pdp:8081/pdp/api/getDecision |
| 128 | Authorization:<yourAuth> ClientAuth:<yourClientAuth> |
| 129 | Environment:<environment> Content-Type:application/json < guard_request.json |
| 130 | |
| 131 | | where: |
Saryu Shah | 73009de | 2017-11-02 16:59:23 +0000 | [diff] [blame] | 132 | | *<yourAuth>* is the string generated from user:pass converted to base64 encoding. |
| 133 | | *<yourClientAuth>* is generated the same way but from the client user and pass. |
| 134 | | *<environment>* is the context of the request. For example: TEST |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 135 | |
| 136 | The guard_request.json should be in the form of the following: |
| 137 | |
| 138 | .. code-block:: json |
| 139 | :caption: guard_request.json |
| 140 | |
| 141 | { |
| 142 | "decisionAttributes": { |
| 143 | "actor": "APPC", |
| 144 | "recipe": "Restart", |
| 145 | "target": "test13", |
Michael Mokry | e957a1d | 2018-09-10 15:23:15 -0500 | [diff] [blame] | 146 | "clname" : "piptest", |
| 147 | "vfCount" : "4" |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 148 | }, |
| 149 | "onapName": "PDPD" |
| 150 | } |
| 151 | |
Saryu Shah | d14620d | 2017-11-03 21:02:26 +0000 | [diff] [blame] | 152 | A response containing a “PERMIT” or “DENY” in uppercase is returned as follows: |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 153 | |
| 154 | .. code-block:: json |
| 155 | :caption: Response |
| 156 | |
| 157 | { |
| 158 | "decision": "PERMIT", |
| 159 | "details": "Decision Permit. OK!" |
| 160 | } |
| 161 | |
| 162 | |
Saryu Shah | 4300d57 | 2017-11-02 13:13:59 +0000 | [diff] [blame] | 163 | End of Document |
Saryu Shah | b5ce885 | 2017-11-02 00:56:03 +0000 | [diff] [blame] | 164 | |
Saryu Shah | 83f3ae3 | 2017-11-06 23:18:08 +0000 | [diff] [blame] | 165 | .. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Creating+and+Using+Guard+Policies |
| 166 | |
| 167 | |