-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct type for ACL src field (#13)
I incorrectly copied this over as a slice instead of a string. This commit fixes that. Signed-off-by: David Bond <[email protected]>
- Loading branch information
1 parent
fd197fb
commit b0ce196
Showing
4 changed files
with
154 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,51 +38,65 @@ func TestACL_Unmarshal(t *testing.T) { | |
Expected: tailscale.ACL{ | ||
ACLs: []tailscale.ACLEntry{ | ||
{ | ||
Action: "accept", | ||
Ports: []string{"*:*"}, | ||
Users: []string{"*"}, | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"autogroup:members"}, | ||
Destination: []string{"autogroup:self:*"}, | ||
Protocol: "", | ||
}, | ||
}, | ||
TagOwners: map[string][]string{ | ||
"tag:example": {"group:example"}, | ||
}, | ||
Hosts: map[string]string{ | ||
"example-host-1": "100.100.100.100", | ||
"example-host-2": "100.100.101.100/24", | ||
}, | ||
DERPMap: &tailscale.ACLDERPMap{ | ||
Regions: map[int]*tailscale.ACLDERPRegion{ | ||
900: { | ||
RegionID: 900, | ||
RegionCode: "example", | ||
RegionName: "example", | ||
Nodes: []*tailscale.ACLDERPNode{ | ||
{ | ||
Name: "1", | ||
RegionID: 900, | ||
HostName: "example.com", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"group:dev"}, | ||
Destination: []string{"tag:dev:*"}, | ||
Protocol: "", | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"group:devops"}, | ||
Destination: []string{"tag:prod:*"}, | ||
Protocol: "", | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"autogroup:members"}, | ||
Destination: []string{"tag:monitoring:80,443"}, | ||
Protocol: "", | ||
}, | ||
OmitDefaultRegions: false, | ||
}, | ||
Groups: map[string][]string{ | ||
"group:example": { | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
"group:dev": {"[email protected]", "[email protected]"}, | ||
"group:devops": {"[email protected]"}, | ||
}, | ||
Hosts: map[string]string(nil), | ||
TagOwners: map[string][]string{ | ||
"tag:dev": {"group:devops"}, | ||
"tag:monitoring": {"group:devops"}, | ||
"tag:prod": {"group:devops"}, | ||
}, | ||
DERPMap: (*tailscale.ACLDERPMap)(nil), | ||
Tests: []tailscale.ACLTest{ | ||
{ | ||
User: "[email protected]", | ||
Allow: []string{"example-host-1:22", "example-host-2:80"}, | ||
Deny: []string{"exapmle-host-2:100"}, | ||
User: "", | ||
Allow: []string(nil), | ||
Deny: []string(nil), | ||
Source: "[email protected]", | ||
Destination: "", | ||
Accept: []string{"tag:prod:80"}, | ||
}, | ||
{ | ||
User: "[email protected]", | ||
Allow: []string{"100.60.3.4:22"}, | ||
}, | ||
User: "", | ||
Allow: []string(nil), | ||
Deny: []string{"tag:prod:80"}, | ||
Source: "[email protected]", | ||
Destination: "", | ||
Accept: []string{"tag:dev:80"}}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -93,51 +107,65 @@ func TestACL_Unmarshal(t *testing.T) { | |
Expected: tailscale.ACL{ | ||
ACLs: []tailscale.ACLEntry{ | ||
{ | ||
Action: "accept", | ||
Ports: []string{"*:*"}, | ||
Users: []string{"*"}, | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"autogroup:members"}, | ||
Destination: []string{"autogroup:self:*"}, | ||
Protocol: "", | ||
}, | ||
}, | ||
TagOwners: map[string][]string{ | ||
"tag:example": {"group:example"}, | ||
}, | ||
Hosts: map[string]string{ | ||
"example-host-1": "100.100.100.100", | ||
"example-host-2": "100.100.101.100/24", | ||
}, | ||
DERPMap: &tailscale.ACLDERPMap{ | ||
Regions: map[int]*tailscale.ACLDERPRegion{ | ||
900: { | ||
RegionID: 900, | ||
RegionCode: "example", | ||
RegionName: "example", | ||
Nodes: []*tailscale.ACLDERPNode{ | ||
{ | ||
Name: "1", | ||
RegionID: 900, | ||
HostName: "example.com", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"group:dev"}, | ||
Destination: []string{"tag:dev:*"}, | ||
Protocol: "", | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"group:devops"}, | ||
Destination: []string{"tag:prod:*"}, | ||
Protocol: "", | ||
}, | ||
{ | ||
Action: "accept", | ||
Ports: []string(nil), | ||
Users: []string(nil), | ||
Source: []string{"autogroup:members"}, | ||
Destination: []string{"tag:monitoring:80,443"}, | ||
Protocol: "", | ||
}, | ||
OmitDefaultRegions: false, | ||
}, | ||
Groups: map[string][]string{ | ||
"group:example": { | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
"group:dev": {"[email protected]", "[email protected]"}, | ||
"group:devops": {"[email protected]"}, | ||
}, | ||
Hosts: map[string]string(nil), | ||
TagOwners: map[string][]string{ | ||
"tag:dev": {"group:devops"}, | ||
"tag:monitoring": {"group:devops"}, | ||
"tag:prod": {"group:devops"}, | ||
}, | ||
DERPMap: (*tailscale.ACLDERPMap)(nil), | ||
Tests: []tailscale.ACLTest{ | ||
{ | ||
User: "[email protected]", | ||
Allow: []string{"example-host-1:22", "example-host-2:80"}, | ||
Deny: []string{"exapmle-host-2:100"}, | ||
User: "", | ||
Allow: []string(nil), | ||
Deny: []string(nil), | ||
Source: "[email protected]", | ||
Destination: "", | ||
Accept: []string{"tag:prod:80"}, | ||
}, | ||
{ | ||
User: "[email protected]", | ||
Allow: []string{"100.60.3.4:22"}, | ||
}, | ||
User: "", | ||
Allow: []string(nil), | ||
Deny: []string{"tag:prod:80"}, | ||
Source: "[email protected]", | ||
Destination: "", | ||
Accept: []string{"tag:dev:80"}}, | ||
}, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,41 @@ | ||
{ | ||
// Allow all users access to all ports. | ||
"ACLS": [ | ||
{ | ||
"Action": "accept", | ||
"Users": ["*"], | ||
"Ports": ["*:*"] | ||
} | ||
], | ||
"TagOwners": { | ||
"tag:example": [ | ||
"group:example", | ||
] | ||
}, | ||
"Groups": { | ||
"group:example": [ | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
}, | ||
"Hosts": { | ||
"example-host-1": "100.100.100.100", | ||
"example-host-2": "100.100.101.100/24", | ||
"groups": { | ||
// Alice and Bob are in group:dev | ||
"group:dev": ["[email protected]", "[email protected]",], | ||
// Carl is in group:devops | ||
"group:devops": ["[email protected]",], | ||
}, | ||
"DerpMap": { | ||
"Regions": { | ||
"900": { | ||
"RegionID": 900, | ||
"RegionCode": "example", | ||
"RegionName": "example", | ||
"Nodes": [{ | ||
"Name": "1", | ||
"RegionID": 900, | ||
"HostName": "example.com" | ||
}] | ||
} | ||
} | ||
"acls": [ | ||
// all employees can access their own devices | ||
{ "action": "accept", "src": ["autogroup:members"], "dst": ["autogroup:self:*"] }, | ||
// users in group:dev can access devices tagged tag:dev | ||
{ "action": "accept", "src": ["group:dev"], "dst": ["tag:dev:*"] }, | ||
// users in group:devops can access devices tagged tag:prod | ||
{ "action": "accept", "src": ["group:devops"], "dst": ["tag:prod:*"] }, | ||
// all employees can access devices tagged tag:monitoring on | ||
// ports 80 and 443 | ||
{ "action": "accept", "src": ["autogroup:members"], "dst": ["tag:monitoring:80,443"] }, | ||
], | ||
"tagOwners": { | ||
// users in group:devops can apply the tag tag:monitoring | ||
"tag:monitoring": ["group:devops"], | ||
// users in group:devops can apply the tag tag:dev | ||
"tag:dev": ["group:devops"], | ||
// users in group:devops can apply the tag tag:prod | ||
"tag:prod": ["group:devops"], | ||
}, | ||
"Tests": [ | ||
"tests": [ | ||
{ | ||
"User": "user1@example.com", | ||
"Allow": ["example-host-1:22", "example-host-2:80"], | ||
"Deny": ["exapmle-host-2:100"], | ||
"src": "carl@example.com", | ||
// test that Carl can access devices tagged tag:prod on port 80 | ||
"accept": ["tag:prod:80"], | ||
}, | ||
{ | ||
"User": "[email protected]", | ||
"Allow": ["100.60.3.4:22"], | ||
} | ||
] | ||
"src": "[email protected]", | ||
// test that Alice can access devices tagged tag:dev on port 80 | ||
"accept": ["tag:dev:80"], | ||
// test that Alice cannot access devices tagged tag:prod on port 80 | ||
"deny": ["tag:prod:80"], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,28 @@ | ||
{ | ||
"acls": [ | ||
{ | ||
"action": "accept", | ||
"users": ["*"], | ||
"ports": ["*:*"] | ||
} | ||
], | ||
"tagowners": { | ||
"tag:example": [ | ||
"group:example" | ||
] | ||
}, | ||
"groups": { | ||
"group:example": [ | ||
"[email protected]", | ||
"[email protected]" | ||
] | ||
"group:dev": ["[email protected]", "[email protected]"], | ||
"group:devops": ["[email protected]"] | ||
}, | ||
"hosts": { | ||
"example-host-1": "100.100.100.100", | ||
"example-host-2": "100.100.101.100/24" | ||
}, | ||
"derpMap": { | ||
"regions": { | ||
"900": { | ||
"regionID": 900, | ||
"regionCode": "example", | ||
"regionName": "example", | ||
"nodes": [{ | ||
"name": "1", | ||
"regionID": 900, | ||
"hostName": "example.com" | ||
}] | ||
} | ||
} | ||
"acls": [ | ||
{ "action": "accept", "src": ["autogroup:members"], "dst": ["autogroup:self:*"] }, | ||
{ "action": "accept", "src": ["group:dev"], "dst": ["tag:dev:*"] }, | ||
{ "action": "accept", "src": ["group:devops"], "dst": ["tag:prod:*"] }, | ||
{ "action": "accept", "src": ["autogroup:members"], "dst": ["tag:monitoring:80,443"] } | ||
], | ||
"tagOwners": { | ||
"tag:monitoring": ["group:devops"], | ||
"tag:dev": ["group:devops"], | ||
"tag:prod": ["group:devops"] | ||
}, | ||
"tests": [ | ||
{ | ||
"user": "[email protected]", | ||
"allow": ["example-host-1:22", "example-host-2:80"], | ||
"deny": ["exapmle-host-2:100"] | ||
"src": "[email protected]", | ||
"accept": ["tag:prod:80"] | ||
}, | ||
{ | ||
"user": "[email protected]", | ||
"allow": ["100.60.3.4:22"] | ||
"src": "[email protected]", | ||
"accept": ["tag:dev:80"], | ||
"deny": ["tag:prod:80"] | ||
} | ||
] | ||
} |