Commit 807d8a45 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

feat: remove unused keyshare /users/isAuthorized endpoint

parent c469e6a9
......@@ -120,7 +120,6 @@ func (s *Server) Handler() http.Handler {
router.Group(func(router chi.Router) {
router.Use(s.userMiddleware)
router.Use(s.authorizationMiddleware)
router.Post("/users/isAuthorized", s.handleValidate)
router.Post("/prove/getCommitments", s.handleCommitments)
router.Post("/prove/getResponse", s.handleResponse)
})
......@@ -281,15 +280,6 @@ func (s *Server) generateResponse(user *User, authorization string, challenge *b
return proofResponse, nil
}
// /users/isAuthorized
func (s *Server) handleValidate(w http.ResponseWriter, r *http.Request) {
if r.Context().Value("hasValidAuthorization").(bool) {
server.WriteJson(w, &irma.KeyshareAuthorization{Status: "authorized", Candidates: []string{"pin"}})
} else {
server.WriteJson(w, &irma.KeyshareAuthorization{Status: "expired", Candidates: []string{"pin"}})
}
}
// /users/verify/pin
func (s *Server) handleVerifyPin(w http.ResponseWriter, r *http.Request) {
// Extract request
......
......@@ -74,9 +74,9 @@ func TestServerHandleRegister(t *testing.T) {
)
}
func TestServerHandleValidate(t *testing.T) {
func TestPinTries(t *testing.T) {
db := createDB(t)
keyshareServer, httpServer := StartKeyshareServer(t, db, "")
keyshareServer, httpServer := StartKeyshareServer(t, &testDB{db: db, ok: true, tries: 1, wait: 0, err: nil}, "")
defer StopKeyshareServer(t, keyshareServer, httpServer)
var jwtMsg irma.KeysharePinStatus
......@@ -86,41 +86,6 @@ func TestServerHandleValidate(t *testing.T) {
)
require.Equal(t, "success", jwtMsg.Status)
var msg irma.KeyshareAuthorization
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/isAuthorized",
"", http.Header{
"X-IRMA-Keyshare-Username": []string{"testusername"},
"Authorization": []string{jwtMsg.Message},
},
200, &msg,
)
assert.Equal(t, "authorized", msg.Status)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/isAuthorized",
"", http.Header{
"X-IRMA-Keyshare-Username": []string{"testusername"},
"Authorization": []string{"Bearer " + jwtMsg.Message},
},
200, &msg,
)
assert.Equal(t, "authorized", msg.Status)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/isAuthorized",
"", http.Header{
"X-IRMA-Keyshare-Username": []string{"testusername"},
"Authorization": []string{"eyalksjdf.aljsdklfesdfhas.asdfhasdf"},
},
200, &msg,
)
assert.Equal(t, "expired", msg.Status)
}
func TestPinTries(t *testing.T) {
db := createDB(t)
keyshareServer, httpServer := StartKeyshareServer(t, &testDB{db: db, ok: true, tries: 1, wait: 0, err: nil}, "")
defer StopKeyshareServer(t, keyshareServer, httpServer)
var jwtMsg irma.KeysharePinStatus
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/verify/pin",
`{"id":"testusername","pin":"puZGbaLDmFywGhFDi4vW2G87Zh"}`, nil,
200, &jwtMsg,
......@@ -165,14 +130,6 @@ func TestMissingUser(t *testing.T) {
keyshareServer, httpServer := StartKeyshareServer(t, NewMemoryDB(), "")
defer StopKeyshareServer(t, keyshareServer, httpServer)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/isAuthorized",
"", http.Header{
"X-IRMA-Keyshare-Username": []string{"doesnotexist"},
"Authorization": []string{"ey.ey.ey"},
},
403, nil,
)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/users/verify/pin",
`{"id":"doesnotexist","pin":"bla"}`, nil,
403, nil,
......
Markdown is supported
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