Unverified Commit 2a599d69 authored by Tomas's avatar Tomas Committed by GitHub
Browse files

Merge pull request #65 from privacybydesign/client-return-url

Client return url
parents d6e62a7b 33fe0e30
......@@ -99,7 +99,7 @@ var JwtServerConfiguration = &requestorserver.Configuration{
},
Port: 48682,
DisableRequestorAuthentication: false,
MaxRequestAge: 3,
MaxRequestAge: 3,
Permissions: requestorserver.Permissions{
Disclosing: []string{"*"},
Signing: []string{"*"},
......@@ -122,7 +122,7 @@ var JwtServerConfiguration = &requestorserver.Configuration{
StaticSessions: map[string]interface{}{
"staticsession": irma.ServiceProviderRequest{
RequestorBaseRequest: irma.RequestorBaseRequest{
CallbackUrl: "http://localhost:48685",
CallbackURL: "http://localhost:48685",
},
Request: &irma.DisclosureRequest{
BaseRequest: irma.BaseRequest{LDContext: irma.LDContextDisclosureRequest},
......
......@@ -83,3 +83,6 @@ func (h *keyshareEnrollmentHandler) KeyshareEnrollmentMissing(manager irma.Schem
func (h *keyshareEnrollmentHandler) UnsatisfiableRequest(request irma.SessionRequest, ServerName irma.TranslatedString, missing MissingAttributes) {
h.fail(errors.New("Keyshare enrollment failed: unsatisfiable"))
}
func (h *keyshareEnrollmentHandler) ClientReturnURLSet(clientReturnURL string) {
h.fail(errors.New("Keyshare enrollment session unexpectedly found an external return url"))
}
......@@ -30,6 +30,7 @@ type PinHandler func(proceed bool, pin string)
// A Handler contains callbacks for communication to the user.
type Handler interface {
StatusUpdate(action irma.Action, status irma.Status)
ClientReturnURLSet(clientReturnURL string)
Success(result string)
Cancelled()
Failure(err *irma.SessionError)
......@@ -309,6 +310,12 @@ func (session *session) processSessionInfo() {
go session.doSession(proceed)
})
session.Handler.StatusUpdate(session.Action, irma.StatusConnected)
// Handle ClientReturnURL if one is found in the session request
if session.request.Base().ClientReturnURL != "" {
session.Handler.ClientReturnURLSet(session.request.Base().ClientReturnURL)
}
switch session.Action {
case irma.ActionDisclosing:
session.Handler.RequestVerificationPermission(
......
......@@ -34,6 +34,8 @@ type BaseRequest struct {
legacy bool // Whether or not this was deserialized from a legacy (pre-condiscon) request
Type Action `json:"type,omitempty"` // Session type, only used in legacy code
ClientReturnURL string `json:"clientReturnUrl,omitempty"` // URL to proceed to when IRMA session is completed
}
// An AttributeCon is only satisfied if all of its containing attribute requests are satisfied.
......@@ -108,7 +110,7 @@ type ServerJwt struct {
type RequestorBaseRequest struct {
ResultJwtValidity int `json:"validity,omitempty"` // Validity of session result JWT in seconds
ClientTimeout int `json:"timeout,omitempty"` // Wait this many seconds for the IRMA app to connect before the session times out
CallbackUrl string `json:"callbackUrl,omitempty"` // URL to post session result to
CallbackURL string `json:"callbackUrl,omitempty"` // URL to post session result to
}
// RequestorRequest is the message with which requestors start an IRMA session. It contains a
......
......@@ -271,7 +271,7 @@ func (conf *Configuration) initialize() error {
if action != irma.ActionDisclosing && action != irma.ActionSigning {
return errors.Errorf("static session %s must be either a disclosing or signing session", name)
}
if rrequest.Base().CallbackUrl == "" {
if rrequest.Base().CallbackURL == "" {
return errors.Errorf("static session %s has no callback URL", name)
}
conf.staticSessions[name] = rrequest
......
......@@ -340,7 +340,7 @@ func (s *Server) handleCreate(w http.ResponseWriter, r *http.Request) {
return
}
}
if rrequest.Base().CallbackUrl != "" && s.conf.jwtPrivateKey == nil {
if rrequest.Base().CallbackURL != "" && s.conf.jwtPrivateKey == nil {
s.conf.Logger.WithFields(logrus.Fields{"requestor": requestor}).Warn("Requestor provided callbackUrl but no JWT private key is installed")
server.WriteError(w, server.ErrorUnsupported, "")
return
......@@ -547,7 +547,7 @@ func (s *Server) resultJwt(sessionresult *server.SessionResult) (string, error)
}
func (s *Server) doResultCallback(result *server.SessionResult) {
callbackUrl := s.irmaserv.GetRequest(result.Token).Base().CallbackUrl
callbackUrl := s.irmaserv.GetRequest(result.Token).Base().CallbackURL
if callbackUrl == "" {
return
}
......
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