From 192636d160b724fe5a62420943742a22370f072a Mon Sep 17 00:00:00 2001 From: Sietse Ringers Date: Mon, 7 Oct 2019 14:36:03 +0200 Subject: [PATCH] refactor: improve internal server endpoints URL structure --- internal/servercore/api.go | 4 ++-- internal/sessiontest/session_test.go | 2 +- irma/cmd/session.go | 4 ++-- server/requestorserver/server.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/servercore/api.go b/internal/servercore/api.go index 750478b44..b70eb3ecb 100644 --- a/internal/servercore/api.go +++ b/internal/servercore/api.go @@ -206,7 +206,7 @@ func (s *Server) StartSession(req interface{}) (*irma.Qr, string, error) { } return &irma.Qr{ Type: action, - URL: s.conf.URL + session.clientToken, + URL: s.conf.URL + "session/" + session.clientToken, }, session.token, nil } @@ -238,7 +238,7 @@ func (s *Server) CancelSession(token string) error { } func ParsePath(path string) (string, string, error) { - pattern := regexp.MustCompile("(\\w+)/?(|commitments|proofs|status|statusevents)$") + pattern := regexp.MustCompile("session/(\\w+)/?(|commitments|proofs|status|statusevents)$") matches := pattern.FindStringSubmatch(path) if len(matches) != 3 { return "", "", server.LogWarning(errors.Errorf("Invalid URL: %s", path)) diff --git a/internal/sessiontest/session_test.go b/internal/sessiontest/session_test.go index 1685197b6..79f029d86 100644 --- a/internal/sessiontest/session_test.go +++ b/internal/sessiontest/session_test.go @@ -410,7 +410,7 @@ func TestStaticQRSession(t *testing.T) { // setup static QR and other variables qr := &irma.Qr{ Type: irma.ActionRedirect, - URL: "http://localhost:48682/irma/-/static/staticsession", + URL: "http://localhost:48682/irma/session/staticsession", } bts, err := json.Marshal(qr) require.NoError(t, err) diff --git a/irma/cmd/session.go b/irma/cmd/session.go index 886185eaf..b78e29099 100644 --- a/irma/cmd/session.go +++ b/irma/cmd/session.go @@ -47,7 +47,7 @@ irma session --server http://localhost:48680 --authmethod token --key mytoken -- if err != nil { die("", err) } - + // Make sure we always run with latest configuration irmaconfig.UpdateSchemes() @@ -231,7 +231,7 @@ func init() { if err != nil { logger.Warn("Could not determine local IP address: ", err.Error()) } else { - defaulturl = "http://" + defaulturl + ":port" + defaulturl = "http://" + defaulturl + ":port/session" } flags := sessionCmd.Flags() diff --git a/server/requestorserver/server.go b/server/requestorserver/server.go index 0f3d04bab..78f23c225 100644 --- a/server/requestorserver/server.go +++ b/server/requestorserver/server.go @@ -177,7 +177,7 @@ func (s *Server) attachClientEndpoints(router *chi.Mux) { if s.conf.Verbose >= 2 { r.Use(s.logHandler("staticsession", true, true, true)) } - r.Post("/irma/-/static/{name}", s.handleCreateStatic) + r.Post("/irma/session/{name}", s.handleCreateStatic) }) }