Skip to content

Commit

Permalink
Return error in getClientRequest and getRequest instead of RemoteError
Browse files Browse the repository at this point in the history
  • Loading branch information
ivard committed Aug 5, 2020
1 parent 346eeb0 commit 136e56e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
20 changes: 15 additions & 5 deletions server/irmaserver/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ func (session *session) handleGetClientRequest(min, max *irma.ProtocolVersion, c

if session.version.Below(2, 7) {
// These versions do not support the ClientRequest format, so send the SessionRequest.
request, rerr := session.getRequest()
return &request, rerr
request, err := session.getRequest()
if err != nil {
return nil, session.fail(server.ErrorRevocation, err.Error())
}
return &request, nil
}
info, err := session.getClientRequest()
if err != nil {
return nil, session.fail(server.ErrorRevocation, err.Error())
}
info, rerr := session.getClientRequest()
return info, rerr
return info, nil
}

func (session *session) handleGetStatus() (server.Status, *irma.RemoteError) {
Expand Down Expand Up @@ -305,8 +311,12 @@ func (s *Server) handleSessionGetRequest(w http.ResponseWriter, r *http.Request)
server.WriteError(w, server.ErrorUnexpectedRequest, "Endpoint is not support in used protocol version")
return
}
var rerr *irma.RemoteError
request, err := session.getRequest()
server.WriteResponse(w, request, err)
if err != nil {
rerr = session.fail(server.ErrorRevocation, err.Error())
}
server.WriteResponse(w, request, rerr)
}

func (s *Server) handleFrontendOptionsPost(w http.ResponseWriter, r *http.Request) {
Expand Down
12 changes: 6 additions & 6 deletions server/irmaserver/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,32 +286,32 @@ func (session *session) getProofP(commitments *irma.IssueCommitmentMessage, sche
return session.kssProofs[scheme], nil
}

func (session *session) getClientRequest() (*irma.ClientRequest, *irma.RemoteError) {
func (session *session) getClientRequest() (*irma.ClientRequest, error) {
info := irma.ClientRequest{
LDContext: irma.LDContextClientRequest,
ProtocolVersion: session.version,
Options: &session.options,
}

if session.options.BindingMethod == irma.BindingMethodNone {
request, rerr := session.getRequest()
if rerr != nil {
return nil, rerr
request, err := session.getRequest()
if err != nil {
return nil, err
}
info.Request = request
}
return &info, nil
}

func (session *session) getRequest() (irma.SessionRequest, *irma.RemoteError) {
func (session *session) getRequest() (irma.SessionRequest, error) {
// In case of issuance requests, strip revocation keys from []CredentialRequest
isreq, issuing := session.request.(*irma.IssuanceRequest)
if !issuing {
return session.request, nil
}
cpy, err := copyObject(isreq)
if err != nil {
return nil, session.fail(server.ErrorRevocation, err.Error())
return nil, err
}
for _, cred := range cpy.(*irma.IssuanceRequest).Credentials {
cred.RevocationSupported = cred.RevocationKey != ""
Expand Down

0 comments on commit 136e56e

Please sign in to comment.