Skip to content
GitLab
Menu
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
00d4304b
Commit
00d4304b
authored
Jun 11, 2019
by
Sietse Ringers
Browse files
feat: return pre-condiscon session result in server sessions started with legacy requests
parent
621ab863
Changes
5
Hide whitespace changes
Inline
Side-by-side
internal/servercore/sessions.go
View file @
00d4304b
...
...
@@ -155,6 +155,7 @@ 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
,
...
...
irmago_test.go
View file @
00d4304b
...
...
@@ -460,6 +460,7 @@ func TestSessionRequests(t *testing.T) {
for
_
,
tst
:=
range
tests
{
require
.
NoError
(
t
,
json
.
Unmarshal
([]
byte
(
tst
.
oldJson
),
tst
.
old
))
require
.
NoError
(
t
,
json
.
Unmarshal
([]
byte
(
tst
.
currentJson
),
tst
.
current
))
tst
.
old
.
Base
()
.
legacy
=
false
require
.
True
(
t
,
reflect
.
DeepEqual
(
tst
.
old
,
tst
.
expected
),
"Legacy %s did not unmarshal to expected value"
,
reflect
.
TypeOf
(
tst
.
old
)
.
String
())
require
.
True
(
t
,
reflect
.
DeepEqual
(
tst
.
current
,
tst
.
expected
),
"%s did not unmarshal to expected value"
,
reflect
.
TypeOf
(
tst
.
old
)
.
String
())
...
...
legacy.go
View file @
00d4304b
...
...
@@ -198,6 +198,7 @@ func (dr *DisclosureRequest) UnmarshalJSON(bts []byte) (err error) {
return
err
}
dr
.
BaseRequest
=
legacy
.
BaseRequest
dr
.
legacy
=
true
dr
.
Version
=
2
dr
.
Disclose
,
dr
.
Labels
=
convertDisjunctions
(
legacy
.
Content
)
...
...
@@ -255,6 +256,7 @@ func (sr *SignatureRequest) UnmarshalJSON(bts []byte) (err error) {
return
err
}
sr
.
BaseRequest
=
legacy
.
BaseRequest
sr
.
legacy
=
true
sr
.
Version
=
2
sr
.
Disclose
,
sr
.
Labels
=
convertDisjunctions
(
legacy
.
Content
)
sr
.
Message
=
legacy
.
Message
...
...
@@ -307,6 +309,7 @@ func (ir *IssuanceRequest) UnmarshalJSON(bts []byte) (err error) {
return
err
}
ir
.
BaseRequest
=
legacy
.
BaseRequest
ir
.
legacy
=
true
ir
.
Version
=
2
ir
.
Credentials
=
legacy
.
Credentials
ir
.
Disclose
,
ir
.
Labels
=
convertDisjunctions
(
legacy
.
Disclose
)
...
...
requests.go
View file @
00d4304b
...
...
@@ -27,8 +27,8 @@ type BaseRequest struct {
Nonce
*
big
.
Int
`json:"nonce,omitempty"`
ProtocolVersion
*
ProtocolVersion
`json:"protocolVersion,omitempty"`
// cache for Identifiers() method
ids
*
IrmaIdentifierSet
ids
*
IrmaIdentifierSet
// cache for Identifiers() method
legacy
bool
}
// An AttributeCon is only satisfied if all of its containing attribute requests are satisfied.
...
...
@@ -177,6 +177,10 @@ var (
bigOne
=
big
.
NewInt
(
1
)
)
func
(
b
*
BaseRequest
)
Legacy
()
bool
{
return
b
.
legacy
}
func
(
b
*
BaseRequest
)
GetContext
()
*
big
.
Int
{
if
b
.
Context
==
nil
{
return
bigOne
...
...
server/api.go
View file @
00d4304b
...
...
@@ -82,6 +82,8 @@ type SessionResult struct {
Disclosed
[][]
*
irma
.
DisclosedAttribute
`json:"disclosed,omitempty"`
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
}
// Status is the status of an IRMA session.
...
...
@@ -95,6 +97,28 @@ const (
StatusTimeout
Status
=
"TIMEOUT"
// Session timed out
)
// 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
))
}
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
})
}
func
(
conf
*
Configuration
)
PrivateKey
(
id
irma
.
IssuerIdentifier
)
(
sk
*
gabi
.
PrivateKey
,
err
error
)
{
sk
=
conf
.
IssuerPrivateKeys
[
id
]
if
sk
==
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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