Templating creating new policy

This commit is contained in:
2026-04-02 01:53:12 -04:00
parent 096bf36c2f
commit ffd3465866
6 changed files with 244 additions and 138 deletions

25
main.go
View File

@@ -1,6 +1,7 @@
package main
import (
"libshared"
"log"
"net/http"
)
@@ -8,20 +9,28 @@ import (
// Document represents the expected JSON structure
// You can modify this struct to match your actual data needs
type Policy struct {
PolicyIdentifier string `json:"pid"`
Comment string `json:"comment"`
Effect string `json:"effect"`
Actions []string `json:"actions"`
Resources []string `json:"resources"`
Name string `json:"name"`
Description string `json:"description"`
Conditions []Condition `json:"conditions"`
}
// Condition represents each item in the "conditions" array
type Condition struct {
StatementID string `json:"statementid"`
Principal []string `json:"principals"`
Actions []string `json:"actions"`
Source []string `json:"source"`
Effect string `json:"effect"`
Operator string `json:"operator"`
}
func main() {
pool = getDbPool()
pool = libshared.GetDbPool()
log.Println("Policy Manager service started")
http.HandleFunc("/iam/create-policy", CreatePolicy)
http.HandleFunc("/iam/list-policy", ListPolicy)
http.HandleFunc("/policy/create-policy", CreatePolicy)
http.HandleFunc("/policy/list-policy", ListPolicy)
log.Println("Server running on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}