Laravel Forge JavaScript SDK

Security Rules

Security Rules

Create a security rule

Method

forge.security.create(server_id, site_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const securityRule = await forge.security.create(server_id, site_id, payload);

Payload

1{
2 name: 'Access Restricted',
3 path: null,
4 credentials: [
5 {
6 username: 'taylor.otwell',
7 password: 'password123'
8 },
9 {
10 username: 'james.brooks',
11 password: 'secret123'
12 }
13 ]
14}

Example Response

1{
2 "security_rule": {
3 "id": 15,
4 "name": "Access Restricted",
5 "path": null,
6 "created_at": "2020-07-30 10:11:10",
7 "credentials": [
8 {
9 "id": 20,
10 "username": "taylor.otwell",
11 "created_at": "2020-07-30 10:11:10"
12 },
13 {
14 "id": 21,
15 "username": "james.brooks",
16 "created_at": "2020-07-30 10:11:10"
17 }
18 ]
19 }
20}

List all security rules

Method

forge.security.list(server_id, site_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const securityRules = await forge.security.list(server_id, site_id);

Example Response

1{
2 "security_rules": [
3 {
4 "id": 15,
5 "name": "Access Restricted",
6 "path": null,
7 "created_at": "2020-07-30 10:11:10",
8 "credentials": [
9 {
10 "id": 20,
11 "username": "taylor.otwell",
12 "created_at": "2020-07-30 10:11:10"
13 },
14 {
15 "id": 21,
16 "username": "james.brooks",
17 "created_at": "2020-07-30 10:11:10"
18 }
19 ]
20 }
21 ]
22}

Get a security rule

Method

forge.security.get(server_id, site_id, rule_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const securityRule = await forge.security.get(server_id, site_id, rule_id);

Example Response

1{
2 "security_rule": {
3 "id": 15,
4 "name": "Access Restricted",
5 "path": null,
6 "created_at": "2020-07-30 10:11:10",
7 "credentials": [
8 {
9 "id": 20,
10 "username": "taylor.otwell",
11 "created_at": "2020-07-30 10:11:10"
12 },
13 {
14 "id": 21,
15 "username": "james.brooks",
16 "created_at": "2020-07-30 10:11:10"
17 }
18 ]
19 }
20}

Delete a security rule

Method

forge.security.delete(server_id, site_id, rule_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.security.delete(server_id, site_id, rule_id);

Edit this page on GitHub