|
@@ -30,6 +30,8 @@ var PlatformUserUserPermissionTemplate = models.UserRolePermissionTemplate{
|
|
|
|
|
|
var NetworkAdminAllPermissionTemplate = models.UserRolePermissionTemplate{
|
|
var NetworkAdminAllPermissionTemplate = models.UserRolePermissionTemplate{
|
|
ID: models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkAdmin)),
|
|
ID: models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkAdmin)),
|
|
|
|
+ Name: "Network Admins",
|
|
|
|
+ MetaData: "Users with this role can manage all your networks configuration including adding and removing devices.",
|
|
Default: true,
|
|
Default: true,
|
|
FullAccess: true,
|
|
FullAccess: true,
|
|
NetworkID: models.AllNetworks,
|
|
NetworkID: models.AllNetworks,
|
|
@@ -37,6 +39,8 @@ var NetworkAdminAllPermissionTemplate = models.UserRolePermissionTemplate{
|
|
|
|
|
|
var NetworkUserAllPermissionTemplate = models.UserRolePermissionTemplate{
|
|
var NetworkUserAllPermissionTemplate = models.UserRolePermissionTemplate{
|
|
ID: models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkUser)),
|
|
ID: models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkUser)),
|
|
|
|
+ Name: "Network Users",
|
|
|
|
+ MetaData: "Users with this role Cannot access the admin console, but can connect to nodes in your networks via RAC.",
|
|
Default: true,
|
|
Default: true,
|
|
FullAccess: false,
|
|
FullAccess: false,
|
|
NetworkID: models.AllNetworks,
|
|
NetworkID: models.AllNetworks,
|
|
@@ -75,12 +79,44 @@ func UserRolesInit() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func UserGroupsInit() {
|
|
|
|
+ // create default network groups
|
|
|
|
+ var NetworkGlobalAdminGroup = models.UserGroup{
|
|
|
|
+ ID: models.UserGroupID(fmt.Sprintf("global-%s-grp", models.NetworkAdmin)),
|
|
|
|
+ Default: true,
|
|
|
|
+ Name: "Network Admin Group",
|
|
|
|
+ MetaData: "Users in this group can manage all your networks configuration including adding and removing devices.",
|
|
|
|
+ NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
|
|
+ models.NetworkID("*"): {
|
|
|
|
+ models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkAdmin)): {},
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ var NetworkGlobalUserGroup = models.UserGroup{
|
|
|
|
+ ID: models.UserGroupID(fmt.Sprintf("global-%s-grp", models.NetworkUser)),
|
|
|
|
+ Name: "Network User Group",
|
|
|
|
+ Default: true,
|
|
|
|
+ NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
|
|
+ models.NetworkID("*"): {
|
|
|
|
+ models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkUser)): {},
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ MetaData: "Users in this group cannot access the admin console, but can connect to nodes in your networks via RAC.",
|
|
|
|
+ }
|
|
|
|
+ d, _ := json.Marshal(NetworkGlobalAdminGroup)
|
|
|
|
+ database.Insert(NetworkGlobalAdminGroup.ID.String(), string(d), database.USER_GROUPS_TABLE_NAME)
|
|
|
|
+ d, _ = json.Marshal(NetworkGlobalUserGroup)
|
|
|
|
+ database.Insert(NetworkGlobalUserGroup.ID.String(), string(d), database.USER_GROUPS_TABLE_NAME)
|
|
|
|
+}
|
|
|
|
+
|
|
func CreateDefaultNetworkRolesAndGroups(netID models.NetworkID) {
|
|
func CreateDefaultNetworkRolesAndGroups(netID models.NetworkID) {
|
|
if netID.String() == "" {
|
|
if netID.String() == "" {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
var NetworkAdminPermissionTemplate = models.UserRolePermissionTemplate{
|
|
var NetworkAdminPermissionTemplate = models.UserRolePermissionTemplate{
|
|
ID: models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkAdmin)),
|
|
ID: models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkAdmin)),
|
|
|
|
+ Name: fmt.Sprintf("%s Admin", netID),
|
|
|
|
+ MetaData: fmt.Sprintf("Users with this role can manage your network `%s` configuration including adding and removing devices.", netID),
|
|
Default: true,
|
|
Default: true,
|
|
NetworkID: netID,
|
|
NetworkID: netID,
|
|
FullAccess: true,
|
|
FullAccess: true,
|
|
@@ -89,6 +125,8 @@ func CreateDefaultNetworkRolesAndGroups(netID models.NetworkID) {
|
|
|
|
|
|
var NetworkUserPermissionTemplate = models.UserRolePermissionTemplate{
|
|
var NetworkUserPermissionTemplate = models.UserRolePermissionTemplate{
|
|
ID: models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkUser)),
|
|
ID: models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkUser)),
|
|
|
|
+ Name: fmt.Sprintf("%s User", netID),
|
|
|
|
+ MetaData: fmt.Sprintf("Users Cannot access the admin console, but can connect to nodes in your network `%s` via RAC.", netID),
|
|
Default: true,
|
|
Default: true,
|
|
FullAccess: false,
|
|
FullAccess: false,
|
|
NetworkID: netID,
|
|
NetworkID: netID,
|
|
@@ -118,22 +156,24 @@ func CreateDefaultNetworkRolesAndGroups(netID models.NetworkID) {
|
|
|
|
|
|
// create default network groups
|
|
// create default network groups
|
|
var NetworkAdminGroup = models.UserGroup{
|
|
var NetworkAdminGroup = models.UserGroup{
|
|
- ID: models.UserGroupID(fmt.Sprintf("%s-%s-grp", netID, models.NetworkAdmin)),
|
|
|
|
|
|
+ ID: models.UserGroupID(fmt.Sprintf("%s-%s-grp", netID, models.NetworkAdmin)),
|
|
|
|
+ Name: fmt.Sprintf("%s Admin Group", netID),
|
|
NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
netID: {
|
|
netID: {
|
|
models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkAdmin)): {},
|
|
models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkAdmin)): {},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- MetaData: "The network group was automatically created by Netmaker.",
|
|
|
|
|
|
+ MetaData: fmt.Sprintf("User in this group can manage your network `%s` configuration including adding and removing devices.", netID),
|
|
}
|
|
}
|
|
var NetworkUserGroup = models.UserGroup{
|
|
var NetworkUserGroup = models.UserGroup{
|
|
- ID: models.UserGroupID(fmt.Sprintf("%s-%s-grp", netID, models.NetworkUser)),
|
|
|
|
|
|
+ ID: models.UserGroupID(fmt.Sprintf("%s-%s-grp", netID, models.NetworkUser)),
|
|
|
|
+ Name: fmt.Sprintf("%s User Group", netID),
|
|
NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
|
|
netID: {
|
|
netID: {
|
|
models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkUser)): {},
|
|
models.UserRoleID(fmt.Sprintf("%s-%s", netID, models.NetworkUser)): {},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- MetaData: "The network group was automatically created by Netmaker.",
|
|
|
|
|
|
+ MetaData: fmt.Sprintf("Users in this group cannot access the admin console, but can connect to nodes in your network `%s` via RAC.", netID),
|
|
}
|
|
}
|
|
d, _ = json.Marshal(NetworkAdminGroup)
|
|
d, _ = json.Marshal(NetworkAdminGroup)
|
|
database.Insert(NetworkAdminGroup.ID.String(), string(d), database.USER_GROUPS_TABLE_NAME)
|
|
database.Insert(NetworkAdminGroup.ID.String(), string(d), database.USER_GROUPS_TABLE_NAME)
|
|
@@ -1100,60 +1140,12 @@ func CreateDefaultUserPolicies(netID models.NetworkID) {
|
|
if netID.String() == "" {
|
|
if netID.String() == "" {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // if !logic.IsAclExists(models.AclID(fmt.Sprintf("%s.%s", netID, models.NetworkAdmin))) {
|
|
|
|
- // defaultUserAcl := models.Acl{
|
|
|
|
- // ID: models.AclID(fmt.Sprintf("%s.%s", netID, models.NetworkAdmin)),
|
|
|
|
- // Name: models.NetworkAdmin.String(),
|
|
|
|
- // Default: true,
|
|
|
|
- // NetworkID: netID,
|
|
|
|
- // RuleType: models.UserPolicy,
|
|
|
|
- // Src: []models.AclPolicyTag{
|
|
|
|
- // {
|
|
|
|
- // ID: models.UserRoleAclID,
|
|
|
|
- // Value: fmt.Sprintf("%s-%s", netID, models.NetworkAdmin),
|
|
|
|
- // }},
|
|
|
|
- // Dst: []models.AclPolicyTag{
|
|
|
|
- // {
|
|
|
|
- // ID: models.DeviceAclID,
|
|
|
|
- // Value: fmt.Sprintf("%s.%s", netID, models.RemoteAccessTagName),
|
|
|
|
- // },
|
|
|
|
- // },
|
|
|
|
- // AllowedDirection: models.TrafficDirectionUni,
|
|
|
|
- // Enabled: true,
|
|
|
|
- // CreatedBy: "auto",
|
|
|
|
- // CreatedAt: time.Now().UTC(),
|
|
|
|
- // }
|
|
|
|
- // logic.InsertAcl(defaultUserAcl)
|
|
|
|
- // }
|
|
|
|
- // if !logic.IsAclExists(models.AclID(fmt.Sprintf("%s.%s", netID, models.NetworkUser))) {
|
|
|
|
- // defaultUserAcl := models.Acl{
|
|
|
|
- // ID: models.AclID(fmt.Sprintf("%s.%s", netID, models.NetworkUser)),
|
|
|
|
- // Name: models.NetworkUser.String(),
|
|
|
|
- // Default: true,
|
|
|
|
- // NetworkID: netID,
|
|
|
|
- // RuleType: models.UserPolicy,
|
|
|
|
- // Src: []models.AclPolicyTag{
|
|
|
|
- // {
|
|
|
|
- // ID: models.UserRoleAclID,
|
|
|
|
- // Value: fmt.Sprintf("%s-%s", netID, models.NetworkUser),
|
|
|
|
- // }},
|
|
|
|
- // Dst: []models.AclPolicyTag{
|
|
|
|
- // {
|
|
|
|
- // ID: models.DeviceAclID,
|
|
|
|
- // Value: fmt.Sprintf("%s.%s", netID, models.RemoteAccessTagName),
|
|
|
|
- // }},
|
|
|
|
- // AllowedDirection: models.TrafficDirectionUni,
|
|
|
|
- // Enabled: true,
|
|
|
|
- // CreatedBy: "auto",
|
|
|
|
- // CreatedAt: time.Now().UTC(),
|
|
|
|
- // }
|
|
|
|
- // logic.InsertAcl(defaultUserAcl)
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- if !logic.IsAclExists(models.AclID(fmt.Sprintf("%s.%s-grp", netID, models.NetworkAdmin))) {
|
|
|
|
|
|
+
|
|
|
|
+ if !logic.IsAclExists(fmt.Sprintf("%s.%s-grp", netID, models.NetworkAdmin)) {
|
|
defaultUserAcl := models.Acl{
|
|
defaultUserAcl := models.Acl{
|
|
- ID: models.AclID(fmt.Sprintf("%s.%s-grp", netID, models.NetworkAdmin)),
|
|
|
|
- Name: fmt.Sprintf("%s-grp", models.NetworkAdmin),
|
|
|
|
|
|
+ ID: fmt.Sprintf("%s.%s-grp", netID, models.NetworkAdmin),
|
|
|
|
+ Name: "Network Admin",
|
|
|
|
+ MetaData: "This Policy allows all network admins to communicate with all remote access gateways",
|
|
Default: true,
|
|
Default: true,
|
|
NetworkID: netID,
|
|
NetworkID: netID,
|
|
RuleType: models.UserPolicy,
|
|
RuleType: models.UserPolicy,
|
|
@@ -1175,10 +1167,11 @@ func CreateDefaultUserPolicies(netID models.NetworkID) {
|
|
logic.InsertAcl(defaultUserAcl)
|
|
logic.InsertAcl(defaultUserAcl)
|
|
}
|
|
}
|
|
|
|
|
|
- if !logic.IsAclExists(models.AclID(fmt.Sprintf("%s.%s-grp", netID, models.NetworkUser))) {
|
|
|
|
|
|
+ if !logic.IsAclExists(fmt.Sprintf("%s.%s-grp", netID, models.NetworkUser)) {
|
|
defaultUserAcl := models.Acl{
|
|
defaultUserAcl := models.Acl{
|
|
- ID: models.AclID(fmt.Sprintf("%s.%s-grp", netID, models.NetworkUser)),
|
|
|
|
- Name: fmt.Sprintf("%s-grp", models.NetworkUser),
|
|
|
|
|
|
+ ID: fmt.Sprintf("%s.%s-grp", netID, models.NetworkUser),
|
|
|
|
+ Name: "Network User",
|
|
|
|
+ MetaData: "This Policy allows all network users to communicate with all remote access gateways",
|
|
Default: true,
|
|
Default: true,
|
|
NetworkID: netID,
|
|
NetworkID: netID,
|
|
RuleType: models.UserPolicy,
|
|
RuleType: models.UserPolicy,
|