Skip to content

Commit

Permalink
[#6] Update documentation ACL
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonsen-92 committed Dec 15, 2020
1 parent b057997 commit c4c0bfb
Showing 1 changed file with 120 additions and 37 deletions.
157 changes: 120 additions & 37 deletions doc/acl.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ POST /access
### Database
![](./acl_model.png)


*if need create new database, please write the sql script below*

### Headers
Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | application/json
Email | [email protected]


### Request Payloads
Expand All @@ -46,7 +43,7 @@ HTTP Code | Status | Description
400 | Bad Request | Bad request payload
404 | Not Found | User not found in database
500 | Internal Server Error | some un-handle error in server
200 | OK | OK
201 | Created | Success created new access
```
{
"status_code": "CDC-400",
Expand All @@ -57,34 +54,25 @@ HTTP Code | Status | Description

```
{
"status_code": "CDC-200",
"status_message": "OK",
"status_code": "CDC-201",
"status_message": "Created",
"data": {
"id":2,
"parent_id": 1,
"alias": "Groups",
"acos": [
{
"id": 1,
"_create" : 1,
"_read" : 1,
"_update" : 1,
"_delete" : 1
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
]
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
}
```

### Logic
using <a href="https://book.cakephp.org/4/en/orm/behaviors/tree.html" rel="notfollow">cakephp tree</a> behavior to get lft and rght from parent_id

#### Validation
- parent_id: required and not empty
- alias: required, not empty and unique

*if any special logic, please write down the logic here. thanks*

### Scenario Test

#### Case : Negative Case 1
Expand Down Expand Up @@ -181,40 +169,72 @@ Response Payload:
}
```

#### Case : Negative Case 6

Request Payload :
```
{
"parent_id": 1,
"alias": "Groups"
}
```

Response HTTP Status Code : 400

Response Payload:
```
{
"status_code": "cdc-400",
"status_message": " alias is already exist in acos table",
"data": null
}
```

#### Case : Negative Case 7

Request Payload :
```
{
"parent_id": 1,
"alias": "Groups"
}
```

Response HTTP Status Code : 404

Response Payload:
```
{
"status_code": "cdc-404",
"status_message": " parent_id not found in acos table",
"data": null
}
```

#### Case : Positive Case

Request Payload :
```
{
"parent_id": 1,
"alias": Groups
"alias": "Groups"
}
```

Response HTTP Status Code : 200
Response HTTP Status Code : 201

Response Payload :
```
{
"status_code": "CDC-200",
"status_message": "OK",
"status_code": "CDC-201",
"status_message": "Created",
"data": {
"id":2,
"parent_id": 1,
"alias": "Groups",
"acos": [
{
"id": 1,
"_create" : 1,
"_read" : 1,
"_update" : 1,
"_delete" : 1,
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
]
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
}
```
Expand All @@ -224,6 +244,69 @@ Response Payload :
### Endpoint
GET /access

### Headers
Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
400 | Bad Request | Bad request payload
404 | Not Found | User not found in database
500 | Internal Server Error | some un-handle error in server
200 | OK | OK

{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"acos": [
{
"id":1,
"parent_id": null,
"alias": "Controller",
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
},
{
"id":2,
"parent_id": 1,
"alias": "Index",
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
},
{
"id":3,
"parent_id": 1,
"alias": "Add",
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
},
{
"id":4,
"parent_id": 1,
"alias": "View",
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
},
{
"id":5,
"parent_id": 1,
"alias": "Edit",
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
},
]
}
}

### Logic
- if there is no email header, you get all acos in tree.
- if any email header, you get all acos which is grant to user login (you need join to aros_acos table).

## <a name="view"></a>View

### Endpoint
Expand All @@ -232,12 +315,12 @@ GET /access/:id
## <a name="edit"></a>Edit

### Endpoint
POST /access/:id
PUT /access/:id

## <a name="delete"></a>DELETE

### Endpoint
DEL /access/:id
DELETE /access/:id

## <a name="grant"></a>DELETE

Expand Down

0 comments on commit c4c0bfb

Please sign in to comment.