Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
807d8a45
Commit
807d8a45
authored
Jun 17, 2021
by
Sietse Ringers
Browse files
feat: remove unused keyshare /users/isAuthorized endpoint
parent
c469e6a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/keyshare/keyshareserver/server.go
View file @
807d8a45
...
...
@@ -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
...
...
server/keyshare/keyshareserver/server_test.go
View file @
807d8a45
...
...
@@ -74,9 +74,9 @@ func TestServerHandleRegister(t *testing.T) {
)
}
func
Test
ServerHandleValidate
(
t
*
testing
.
T
)
{
func
Test
PinTries
(
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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment