diff options
Diffstat (limited to 'jwt_mock.go')
| -rw-r--r-- | jwt_mock.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/jwt_mock.go b/jwt_mock.go new file mode 100644 index 0000000..e4a46f5 --- /dev/null +++ b/jwt_mock.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS, POST, PUT") + w.Header().Set("Access-Control-Allow-Headers", "Authorization") + + if r.Method == "OPTIONS" { + w.WriteHeader(http.StatusNoContent) + return + } + + auth := r.Header.Get("Authorization") + if auth != "Basic dXNyOnB3ZA==" { // btoa("usr:pwd") + w.WriteHeader(http.StatusUnauthorized) + return + } + + fmt.Fprint(w, "{\"access_token\": \"JWT_TOKEN_PLACEHOLDER\"}") + }) + + log.Fatal(http.ListenAndServe(":8080", nil)) +} |
