minor tweaks towards JWTs

time box expired before completing this; one of these days...
This commit is contained in:
Daniel J. Summers 2018-03-20 20:26:02 -05:00
parent 8d84bdb2e6
commit b248f7ca7f
3 changed files with 6 additions and 5 deletions

View File

@ -7,9 +7,9 @@ import (
"net/http" "net/http"
"time" "time"
auth0 "github.com/auth0-community/go-auth0" "github.com/auth0-community/go-auth0"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
jose "gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )
// AuthConfig contains the Auth0 configuration passed from the "auth" JSON object. // AuthConfig contains the Auth0 configuration passed from the "auth" JSON object.
@ -45,7 +45,7 @@ func withAuth(next DBHandler, cfg *AuthConfig) DBHandler {
audience := []string{fmt.Sprintf("https://%s/userinfo", cfg.Domain)} audience := []string{fmt.Sprintf("https://%s/userinfo", cfg.Domain)}
configuration := auth0.NewConfiguration(secretProvider, audience, fmt.Sprintf("https://%s/", cfg.Domain), jose.HS256) configuration := auth0.NewConfiguration(secretProvider, audience, fmt.Sprintf("https://%s/", cfg.Domain), jose.HS256)
validator := auth0.NewValidator(configuration) validator := auth0.NewValidator(configuration, nil)
token, err := validator.ValidateRequest(r) token, err := validator.ValidateRequest(r)
@ -77,5 +77,6 @@ func NewRouter(db *sql.DB, cfg *AuthConfig) *httprouter.Router {
router.Handle(route.Method, route.Pattern, withDB(withAuth(route.Func, cfg), db)) router.Handle(route.Method, route.Pattern, withDB(withAuth(route.Func, cfg), db))
} }
} }
// router.ServeFiles("/*filepath", http.Dir("/public"))
return router return router
} }

View File

@ -18,7 +18,7 @@ var routes = Routes{
Route{ Route{
"Journal", "Journal",
"GET", "GET",
"/journal", "/api/journal",
journal, journal,
false, false,
}, },

View File

@ -13,7 +13,7 @@
"test": "npm run unit && npm run e2e", "test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs", "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
"apistart": "cd .. && go build -o mpj-api.exe && mpj-api.exe", "apistart": "cd .. && go build -o mpj-api.exe && mpj-api.exe",
"vue": "node build/build.js prod && go build -o mpj-api.exe && mpj-api.exe" "vue": "node build/build.js prod && cd .. && go build -o mpj-api.exe && mpj-api.exe"
}, },
"dependencies": { "dependencies": {
"auth0-js": "^9.3.3", "auth0-js": "^9.3.3",