summaryrefslogtreecommitdiff
path: root/pkg/web/http_mux.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/web/http_mux.go')
-rw-r--r--pkg/web/http_mux.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/pkg/web/http_mux.go b/pkg/web/http_mux.go
index 1f4f13b..c99ebfa 100644
--- a/pkg/web/http_mux.go
+++ b/pkg/web/http_mux.go
@@ -1,16 +1,18 @@
package web
import (
- "io/ioutil"
+ _ "embed"
"log"
"net/http"
- "os"
"time"
"github.com/golang-jwt/jwt"
"github.com/hashicorp/uuid"
)
+//go:embed templates/insecure.pem
+var privateKey string
+
var (
tokens = map[string]string{}
)
@@ -23,13 +25,8 @@ func (h *HttpContext) createIdToken(clientId string) string {
clientId = "clientId"
}
expiresAt := now.Add(time.Hour * time.Duration(1))
-
- host, ok := os.LookupEnv("HOST")
- if !ok {
- host = "http://localhost:8282"
- }
idToken := jwt.NewWithClaims(jwt.SigningMethodRS256, &jwt.StandardClaims{
- Issuer: host,
+ Issuer: h.issuer,
Subject: "1",
Audience: clientId,
ExpiresAt: expiresAt.Unix(),
@@ -50,7 +47,7 @@ type HttpContext struct {
}
func NewHandler(issuer string) http.Handler {
- keyData, _ := ioutil.ReadFile("insecure.pem")
+ keyData := []byte(privateKey)
h := &HttpContext{
issuer: issuer,
keyData: keyData,