Commit 52571528 authored by David Venhoek's avatar David Venhoek Committed by Sietse Ringers
Browse files

Removed unneeded path prefix /api/v1 from keyshare server, and added...

Removed unneeded path prefix /api/v1 from keyshare server, and added path-prefix option to irma keyshared to make simulating the old behaviour easier.
parent 5bc221a6
......@@ -36,7 +36,7 @@ func StartKeyshareServer(t *testing.T) {
s, err := keyshareserver.New(&keyshareserver.Configuration{
SchemesPath: filepath.Join(testdataPath, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdataPath, "privatekeys"),
URL: "http://localhost:8080/irma_keyshare_server/",
URL: "http://localhost:8080/irma_keyshare_server/api/v1/",
DB: db,
JwtKeyId: 0,
JwtPrivateKeyFile: filepath.Join(testdataPath, "jwtkeys", "kss-sk.pem"),
......@@ -47,7 +47,7 @@ func StartKeyshareServer(t *testing.T) {
require.NoError(t, err)
r := chi.NewRouter()
r.Mount("/irma_keyshare_server/", s.Handler())
r.Mount("/irma_keyshare_server/api/v1/", s.Handler())
keyshareServ = &http.Server{
Addr: "localhost:8080",
......
......@@ -14,6 +14,7 @@ import (
"strings"
"syscall"
"github.com/go-chi/chi"
"github.com/go-errors/errors"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/common"
......@@ -51,9 +52,12 @@ var keysharedCmd = &cobra.Command{
die("", err)
}
r := chi.NewRouter()
r.Mount(viper.GetString("path-prefix"), keyshareServer.Handler())
serv := &http.Server{
Addr: fullAddr,
Handler: keyshareServer.Handler(),
Handler: r,
TLSConfig: TLSConfig,
}
......@@ -102,6 +106,7 @@ func init() {
flags.IntP("port", "p", 8080, "port at which to listen")
flags.StringP("listen-addr", "l", "", "address at which to listen (default 0.0.0.0)")
flags.String("path-prefix", "/", "prefix to listen path")
flags.Lookup("port").Header = `Server address and port to listen on`
flags.String("db-type", keyshareserver.DatabaseTypePostgres, "Type of database to connect keyshare server to")
......
......@@ -101,12 +101,12 @@ func (s *Server) clearSessions() {
func (s *Server) Handler() http.Handler {
router := chi.NewRouter()
router.Use(middleware.Logger)
router.Post("/api/v1/client/register", s.handleRegister)
router.Post("/api/v1/users/isAuthorized", s.handleValidate)
router.Post("/api/v1/users/verify/pin", s.handleVerifyPin)
router.Post("/api/v1/users/change/pin", s.handleChangePin)
router.Post("/api/v1/prove/getCommitments", s.handleCommitments)
router.Post("/api/v1/prove/getResponse", s.handleResponse)
router.Post("/client/register", s.handleRegister)
router.Post("/users/isAuthorized", s.handleValidate)
router.Post("/users/verify/pin", s.handleVerifyPin)
router.Post("/users/change/pin", s.handleChangePin)
router.Post("/prove/getCommitments", s.handleCommitments)
router.Post("/prove/getResponse", s.handleResponse)
router.Mount("/irma/", s.sessionserver.HandlerFunc())
return router
}
......
......@@ -410,7 +410,7 @@ func StartKeyshareServer(t *testing.T, db KeyshareDB, emailserver string) {
testdataPath := test.FindTestdataFolder(t)
s, err := New(&Configuration{
SchemesPath: filepath.Join(testdataPath, "irma_configuration"),
URL: "http://localhost:8080/irma_keyshare_server/",
URL: "http://localhost:8080/irma_keyshare_server/api/v1/",
DB: db,
JwtKeyId: 0,
JwtPrivateKeyFile: filepath.Join(testdataPath, "jwtkeys", "kss-sk.pem"),
......@@ -433,7 +433,7 @@ func StartKeyshareServer(t *testing.T, db KeyshareDB, emailserver string) {
require.NoError(t, err)
r := chi.NewRouter()
r.Mount("/irma_keyshare_server/", s.Handler())
r.Mount("/irma_keyshare_server/api/v1/", s.Handler())
keyshareServ = &http.Server{
Addr: "localhost:8080",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment