Skip to content

Commit eb605dc

Browse files
committed
Removed logs and finetuned docs
1 parent e6044f7 commit eb605dc

File tree

3 files changed

+4
-51
lines changed

3 files changed

+4
-51
lines changed

docs/policy-management.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ A PUT completely replaces the policy within the scope of the client.
118118
The PUT works as a combination of DELETE and POST. It requires a body with the same content type as the [POST request](#creating-policies). This body will be interpreted as the requested policy with some rules.
119119

120120
The PUT process:
121-
1. Find information about the policy. If it does not exist, return with a **status code 400** to indicate that you cannot rewrite a nonexistent policy.
121+
1. Find information about the policy. If it does not exist, return with a **status code 404** to indicate that you cannot rewrite a nonexistent policy.
122122
2. Parse and validate the body, with the same procedure used in the POST endpoint. First, we perform the basic sanitization checks. Upon success, extra checks are performed to see if the new definition stays within the scope of the client:
123123
- Check that the newly defined policy does not define other policies
124124
- Check that the new policy does not contain any rules that do not belong to the client
@@ -143,7 +143,7 @@ The PATCH process:
143143
- Performing DELETE queries on rules out of your scope will simply not work, since they are not part of the isolated store.
144144
- We can easily see exactly when the query goes out of scope by testing the resulting store, separating it in the 5 groups and performing the following checks:
145145
1. If the resulting store has rules out of the clients' scope (indicated by groups **(2)** and **(5)**), we can abort the update and respond with **status code 400**.
146-
2. We can analyze the size of the resulting store. Substracting the amount of quads within reach should result in 0, since no other rules may be added. This test will fail when the client inserts any unrelated quads to its own policy. Upon failure, the server responds with **status code 400**.
146+
2. We can analyze the size of the resulting store. Substracting the amount of quads within reach should result in 0, since no other rules may be added. This test will fail when the client inserts/deletes any unrelated quads to its own policy. Upon failure, the server responds with **status code 400**.
147147
4. The old definition will be replaced with the updated version. Since no real update function for our storage exists, we delete the old policy and add the resulting store from the query, together with the quads out of scope as collected in step 1.
148148

149149
Note that any quads in the original policy that could not be collected by the procedure defined in [GET One Policy](#get-one-policy), will not be part of the newly defined policy.
@@ -155,8 +155,8 @@ The DELETE process:
155155
1. Find the rules defined in the policy.
156156
2. Filter the rules that are assigned by the client, and delete them.
157157
3. Find out if there are rules not assigned by the client.
158-
* if there are other rules, we cannot delete the policy information as well. We delete the rule and its definition triple in the policy.
159-
* if there are no other rules, we can delete the entire policy.
158+
* If there are other rules, we cannot delete the policy information as well. We delete the rule and its definition triple in the policy.
159+
* If there are no other rules, we can delete the entire policy.
160160

161161
This method used to have one rather significant issue, as discussed [later](#delete-fix).
162162

packages/uma/src/util/routeSpecific/policies/CreatePolicies.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,50 +51,16 @@ export async function addPolicies(request: HttpHandlerRequest, store: Store, sto
5151
const totalQuads: Quad[] = [];
5252
if ([...newPolicies].some(id => {
5353
const existingInfo = getPolicyInfo(id, store, clientId);
54-
console.log(`
55-
INITIAL POLICY ${id}
56-
57-
POLICY ITSELF - ${existingInfo.policyDefinitions.length}
58-
${existingInfo.policyDefinitions}
59-
${existingInfo.ownedPolicyRules}
60-
${existingInfo.otherPolicyRules}
61-
62-
OWNED RULES - ${existingInfo.ownedRules.length}
63-
${existingInfo.ownedRules.length}
64-
65-
OTHER RULES - ${existingInfo.otherRules.length}
66-
${existingInfo.otherRules}
67-
68-
TOTAL = ${parsedPolicy.getQuads(null, null, null, null).length}
69-
`)
7054
// None of the policies in the request should already exist
7155
if ([...existingInfo.policyDefinitions, ...existingInfo.ownedPolicyRules, ...existingInfo.otherPolicyRules,
7256
...existingInfo.ownedRules, ...existingInfo.otherRules].length > 0) {
73-
console.log('TEST: ALREADY EXISTS')
7457
return true;
7558
}
7659

7760
const { policyDefinitions, ownedPolicyRules, otherPolicyRules, ownedRules, otherRules } = getPolicyInfo(id, parsedPolicy, clientId);
7861

79-
console.log(`
80-
TEST FOR POLICY ${id}
81-
82-
POLICY ITSELF - ${policyDefinitions.length}
83-
${policyDefinitions}
84-
${ownedPolicyRules}
85-
${otherPolicyRules}
86-
87-
OWNED RULES - ${ownedRules.length}
88-
${ownedRules}
89-
90-
OTHER RULES - ${otherRules.length}
91-
${otherRules}
92-
93-
TOTAL = ${parsedPolicy.getQuads(null, null, null, null).length}
94-
`)
9562
// The policies may not declare rules out of scope
9663
if (otherRules.length !== 0 || otherPolicyRules.length !== 0) {
97-
console.log("TEST: out of scope")
9864
return true;
9965
}
10066

packages/uma/src/util/routeSpecific/policies/EditPolicies.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ export async function editPolicy(request: HttpHandlerRequest, store: Store, stor
2929
}
3030
const query = parseBufferToString(request.body);
3131

32-
console.log(`
33-
POLICY INFORMATION
34-
${ownedPolicyRules}
35-
${ownedRules}
36-
${policyDefinitions}
37-
38-
QUERY:
39-
${query}
40-
`)
41-
42-
4332

4433
// 3. Execute the query on the part of the policy that lays within reach
4534
const policyStore = new Store([...policyDefinitions, ...ownedPolicyRules, ...ownedRules]);
@@ -57,8 +46,6 @@ export async function editPolicy(request: HttpHandlerRequest, store: Store, stor
5746
const initialState = { policyDefinitions, ownedPolicyRules, otherPolicyRules, ownedRules, otherRules };
5847
const newState = getPolicyInfo(policyId, policyStore, clientId);
5948

60-
console.log(`\n--- POLICY STATE CHANGE ---\nInitial State:\n policyDefinitions: ${initialState.policyDefinitions.map(q => q.toString()).join("\n ")}\n ownedPolicyRules: ${initialState.ownedPolicyRules.map(q => q.toString()).join("\n ")}\n otherPolicyRules: ${initialState.otherPolicyRules.map(q => q.toString()).join("\n ")}\n ownedRules: ${initialState.ownedRules.map(q => q.toString()).join("\n ")}\n otherRules: ${initialState.otherRules.map(q => q.toString()).join("\n ")}\nNew State:\n policyDefinitions: ${newState.policyDefinitions.map(q => q.toString()).join("\n ")}\n ownedPolicyRules: ${newState.ownedPolicyRules.map(q => q.toString()).join("\n ")}\n otherPolicyRules: ${newState.otherPolicyRules.map(q => q.toString()).join("\n ")}\n ownedRules: ${newState.ownedRules.map(q => q.toString()).join("\n ")}\n otherRules: ${newState.otherRules.map(q => q.toString()).join("\n ")}\n`);
61-
6249
if (newState.otherRules.length !== 0 || newState.otherPolicyRules.length !== 0)
6350
throw new BadRequestHttpError("Update not allowed: attempted to modify rules not owned by client");
6451

0 commit comments

Comments
 (0)