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
6d25eaad
Commit
6d25eaad
authored
Aug 07, 2019
by
Sietse Ringers
Browse files
fix: missing fields from session result JWT
parent
5578f2e2
Pipeline
#27664
passed with stages
in 5 minutes and 5 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
internal/servercore/sessions.go
View file @
6d25eaad
...
...
@@ -155,10 +155,10 @@ func (s *Server) newSession(action irma.Action, request irma.RequestorRequest) *
conf
:
s
.
conf
,
sessions
:
s
.
sessions
,
result
:
&
server
.
SessionResult
{
Legacy
:
request
.
SessionRequest
()
.
Base
()
.
Legacy
(),
Token
:
token
,
Type
:
action
,
Status
:
server
.
StatusInitialized
,
Legacy
Session
:
request
.
SessionRequest
()
.
Base
()
.
Legacy
(),
Token
:
token
,
Type
:
action
,
Status
:
server
.
StatusInitialized
,
},
}
...
...
server/api.go
View file @
6d25eaad
...
...
@@ -84,7 +84,7 @@ type SessionResult struct {
Signature
*
irma
.
SignedMessage
`json:"signature,omitempty"`
Err
*
irma
.
RemoteError
`json:"error,omitempty"`
Legacy
bool
`json:"-"`
// true if request was started with legacy (i.e. pre-condiscon) session request
Legacy
Session
bool
`json:"-"`
// true if request was started with legacy (i.e. pre-condiscon) session request
}
// Status is the status of an IRMA session.
...
...
@@ -99,25 +99,23 @@ const (
)
// Remove this when dropping support for legacy pre-condiscon session requests
func
(
r
*
SessionResult
)
MarshalJSON
()
([]
byte
,
error
)
{
if
!
r
.
Legacy
{
type
tmpSessionResult
SessionResult
return
json
.
Marshal
((
*
tmpSessionResult
)(
r
))
}
type
LegacySessionResult
struct
{
Token
string
`json:"token"`
Status
Status
`json:"status"`
Type
irma
.
Action
`json:"type"`
ProofStatus
irma
.
ProofStatus
`json:"proofStatus,omitempty"`
Disclosed
[]
*
irma
.
DisclosedAttribute
`json:"disclosed,omitempty"`
Signature
*
irma
.
SignedMessage
`json:"signature,omitempty"`
Err
*
irma
.
RemoteError
`json:"error,omitempty"`
}
// Remove this when dropping support for legacy pre-condiscon session requests
func
(
r
*
SessionResult
)
Legacy
()
*
LegacySessionResult
{
var
disclosed
[]
*
irma
.
DisclosedAttribute
for
_
,
l
:=
range
r
.
Disclosed
{
disclosed
=
append
(
disclosed
,
l
[
0
])
}
return
json
.
Marshal
(
struct
{
Token
string
`json:"token"`
Status
Status
`json:"status"`
Type
irma
.
Action
`json:"type"'`
ProofStatus
irma
.
ProofStatus
`json:"proofStatus,omitempty"`
Disclosed
[]
*
irma
.
DisclosedAttribute
`json:"disclosed,omitempty"`
Signature
*
irma
.
SignedMessage
`json:"signature,omitempty"`
Err
*
irma
.
RemoteError
`json:"error,omitempty"`
}{
r
.
Token
,
r
.
Status
,
r
.
Type
,
r
.
ProofStatus
,
disclosed
,
r
.
Signature
,
r
.
Err
})
return
&
LegacySessionResult
{
r
.
Token
,
r
.
Status
,
r
.
Type
,
r
.
ProofStatus
,
disclosed
,
r
.
Signature
,
r
.
Err
}
}
func
(
conf
*
Configuration
)
PrivateKey
(
id
irma
.
IssuerIdentifier
)
(
sk
*
gabi
.
PrivateKey
,
err
error
)
{
...
...
server/requestorserver/server.go
View file @
6d25eaad
...
...
@@ -387,7 +387,11 @@ func (s *Server) handleResult(w http.ResponseWriter, r *http.Request) {
server
.
WriteError
(
w
,
server
.
ErrorSessionUnknown
,
""
)
return
}
server
.
WriteJson
(
w
,
res
)
if
res
.
LegacySession
{
server
.
WriteJson
(
w
,
res
.
Legacy
())
}
else
{
server
.
WriteJson
(
w
,
res
)
}
}
func
(
s
*
Server
)
handleJwtResult
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -495,20 +499,25 @@ func (s *Server) handlePublicKey(w http.ResponseWriter, r *http.Request) {
}
func
(
s
*
Server
)
resultJwt
(
sessionresult
*
server
.
SessionResult
)
(
string
,
error
)
{
claims
:=
struct
{
jwt
.
StandardClaims
*
server
.
SessionResult
}{
StandardClaims
:
jwt
.
StandardClaims
{
Issuer
:
s
.
conf
.
JwtIssuer
,
IssuedAt
:
time
.
Now
()
.
Unix
(),
Subject
:
string
(
sessionresult
.
Type
)
+
"_result"
,
},
SessionResult
:
sessionresult
,
standardclaims
:=
jwt
.
StandardClaims
{
Issuer
:
s
.
conf
.
JwtIssuer
,
IssuedAt
:
time
.
Now
()
.
Unix
(),
Subject
:
string
(
sessionresult
.
Type
)
+
"_result"
,
}
validity
:=
s
.
irmaserv
.
GetRequest
(
sessionresult
.
Token
)
.
Base
()
.
ResultJwtValidity
if
validity
!=
0
{
claims
.
ExpiresAt
=
time
.
Now
()
.
Unix
()
+
int64
(
validity
)
standardclaims
.
ExpiresAt
=
time
.
Now
()
.
Unix
()
+
int64
(
validity
)
var
claims
jwt
.
Claims
if
sessionresult
.
LegacySession
{
claims
=
struct
{
jwt
.
StandardClaims
*
server
.
LegacySessionResult
}{
standardclaims
,
sessionresult
.
Legacy
()}
}
else
{
claims
=
struct
{
jwt
.
StandardClaims
*
server
.
SessionResult
}{
standardclaims
,
sessionresult
}
}
// Sign the jwt and return it
...
...
version.go
View file @
6d25eaad
...
...
@@ -7,7 +7,7 @@ package irma
import
"github.com/timshannon/bolthold"
// Version of the IRMA command line and libraries
const
Version
=
"0.3.
0
"
const
Version
=
"0.3.
1
"
// go-atum requires a version of bolthold newer than the latest release v1.1, but go-atum does not
// use dep, so by default dep fetches v1.1 which breaks the build. We make bolthold an explicit
...
...
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