summaryrefslogtreecommitdiff
path: root/magefile.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-03-05 13:02:36 -0700
committermo khan <mo@mokhan.ca>2025-03-05 13:02:36 -0700
commite1fe97ff76ac966039347465f79dc96e705f7f25 (patch)
treec0168a0884ce57d8827c4add7667219f04d69faa /magefile.go
parent06a4e0783c1886ca46468c4caeb42a41d56fd956 (diff)
feat: connect the reverse proxy to a casbin policy enforcement and separate hostnames
Diffstat (limited to 'magefile.go')
-rw-r--r--magefile.go44
1 files changed, 32 insertions, 12 deletions
diff --git a/magefile.go b/magefile.go
index 40df5ade..8e1b969b 100644
--- a/magefile.go
+++ b/magefile.go
@@ -16,35 +16,55 @@ import (
var Default = Run
// Run the Identity Provider
-func RunIdp() error {
- return sh.RunV("ruby", "./bin/idp")
+func Idp() error {
+ env := map[string]string{
+ "SCHEME": "http",
+ "PORT": "8282",
+ "HOST": "idp.example.com:8080",
+ }
+ return sh.RunWithV(env, "ruby", "./bin/idp")
}
-// Run the Service Provider
-func RunSp() error {
- return sh.RunV("ruby", "./bin/sp")
+// Run the UI (a.k.a Service Provider)
+func UI() error {
+ env := map[string]string{
+ "SCHEME": "http",
+ "PORT": "8283",
+ "HOST": "ui.example.com:8080",
+ "IDP_HOST": "idp.example.com:8080",
+ }
+ return sh.RunWithV(env, "ruby", "./bin/ui")
}
// Run the API Gateway
-func RunGateway() error {
- return sh.RunV("go", "run", "./cmd/gtwy/main.go")
+func Gateway() error {
+ env := map[string]string{
+ "BIND_ADDR": ":8080",
+ }
+ return sh.RunWithV(env, "go", "run", "./cmd/gtwy/main.go")
}
// Run the REST API
-func RunApi() error {
- return sh.RunV("ruby", "./bin/rest-api")
+func Api() error {
+ env := map[string]string{
+ "SCHEME": "http",
+ "PORT": "8284",
+ "HOST": "localhost:8284",
+ }
+ return sh.RunWithV(env, "ruby", "./bin/api")
}
// Open a web browser to the login page
func Browser() error {
+ url := "http://localhost:8080/ui/sessions/new"
if runtime.GOOS == "linux" {
- return sh.RunV("xdg-open", "http://localhost:8080/sp/sessions/new")
+ return sh.RunV("xdg-open", url)
} else {
- return sh.RunV("open", "http://localhost:8080/sp/sessions/new")
+ return sh.RunV("open", url)
}
}
// Run All the servers
func Run(ctx context.Context) {
- mg.CtxDeps(ctx, RunIdp, RunSp, RunApi, RunGateway)
+ mg.CtxDeps(ctx, Idp, UI, Api, Gateway)
}