mirror of
https://github.com/gravitl/netmaker.git
synced 2026-01-07 03:14:03 +08:00
add acl types api
This commit is contained in:
parent
f3b0bb60f0
commit
a9697f9d7b
2 changed files with 30 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ import (
|
|||
func aclHandlers(r *mux.Router) {
|
||||
r.HandleFunc("/api/v1/acls", logic.SecurityCheck(true, http.HandlerFunc(getAcls))).
|
||||
Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/v1/acls/policy_types", logic.SecurityCheck(true, http.HandlerFunc(getAclPolicyTypes))).
|
||||
r.HandleFunc("/api/v1/acls/policy_types", logic.SecurityCheck(true, http.HandlerFunc(aclPolicyTypes))).
|
||||
Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/v1/acls", logic.SecurityCheck(true, http.HandlerFunc(createAcl))).
|
||||
Methods(http.MethodPost)
|
||||
|
|
@ -25,6 +25,8 @@ func aclHandlers(r *mux.Router) {
|
|||
Methods(http.MethodPut)
|
||||
r.HandleFunc("/api/v1/acls", logic.SecurityCheck(true, http.HandlerFunc(deleteAcl))).
|
||||
Methods(http.MethodDelete)
|
||||
r.HandleFunc("/api/v1/acls/debug", logic.SecurityCheck(true, http.HandlerFunc(aclDebug))).
|
||||
Methods(http.MethodGet)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +36,27 @@ func aclHandlers(r *mux.Router) {
|
|||
// @Accept json
|
||||
// @Success 200 {array} models.SuccessResponse
|
||||
// @Failure 500 {object} models.ErrorResponse
|
||||
func getAclPolicyTypes(w http.ResponseWriter, r *http.Request) {
|
||||
func aclPolicyTypes(w http.ResponseWriter, r *http.Request) {
|
||||
resp := models.AclPolicyTypes{
|
||||
RuleTypes: []models.AclPolicyType{
|
||||
models.DevicePolicy,
|
||||
models.UserPolicy,
|
||||
},
|
||||
SrcGroupTypes: []models.AclGroupType{
|
||||
models.UserAclID,
|
||||
models.UserGroupAclID,
|
||||
models.DeviceAclID,
|
||||
},
|
||||
DstGroupTypes: []models.AclGroupType{
|
||||
models.DeviceAclID,
|
||||
// models.NetmakerIPAclID,
|
||||
// models.NetmakerSubNetRangeAClID,
|
||||
},
|
||||
}
|
||||
logic.ReturnSuccessResponseWithJson(w, r, resp, "fetched acls types")
|
||||
}
|
||||
|
||||
func aclDebug(w http.ResponseWriter, r *http.Request) {
|
||||
nodeID, _ := url.QueryUnescape(r.URL.Query().Get("node"))
|
||||
peerID, _ := url.QueryUnescape(r.URL.Query().Get("peer"))
|
||||
node, err := logic.GetNodeByID(nodeID)
|
||||
|
|
|
|||
|
|
@ -78,3 +78,9 @@ type Acl struct {
|
|||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type AclPolicyTypes struct {
|
||||
RuleTypes []AclPolicyType `json:"policy_types"`
|
||||
SrcGroupTypes []AclGroupType `json:"src_grp_types"`
|
||||
DstGroupTypes []AclGroupType `json:"dst_grp_types"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue