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
b836f687
Commit
b836f687
authored
Aug 02, 2018
by
Sietse Ringers
Browse files
Temporarily disable session logs
parent
1c4b7f98
Changes
3
Hide whitespace changes
Inline
Side-by-side
irmaclient/irmaclient_test.go
View file @
b836f687
...
...
@@ -117,7 +117,7 @@ func TestStorageDeserialization(t *testing.T) {
test
.
ClearTestStorage
(
t
)
}
func
TestLogging
(
t
*
testing
.
T
)
{
func
disabled
TestLogging
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
logs
,
err
:=
client
.
Logs
()
...
...
@@ -135,7 +135,7 @@ func TestLogging(t *testing.T) {
entry
:=
logs
[
len
(
logs
)
-
1
]
require
.
NotNil
(
t
,
entry
)
require
.
Equal
(
t
,
"testip"
,
entry
.
Request
.
GetRequestorName
())
//
require.Equal(t, "testip", entry.Request.GetRequestorName())
require
.
NoError
(
t
,
err
)
issued
,
err
:=
entry
.
GetIssuedCredentials
(
client
.
Configuration
)
require
.
NoError
(
t
,
err
)
...
...
@@ -153,7 +153,7 @@ func TestLogging(t *testing.T) {
entry
=
logs
[
len
(
logs
)
-
1
]
require
.
NotNil
(
t
,
entry
)
require
.
Equal
(
t
,
"testsp"
,
entry
.
Request
.
GetRequestorName
())
//
require.Equal(t, "testsp", entry.Request.GetRequestorName())
require
.
NoError
(
t
,
err
)
disclosed
,
err
=
entry
.
GetDisclosedCredentials
(
client
.
Configuration
)
require
.
NoError
(
t
,
err
)
...
...
@@ -167,7 +167,7 @@ func TestLogging(t *testing.T) {
require
.
True
(
t
,
len
(
logs
)
==
oldLogLength
+
3
)
entry
=
logs
[
len
(
logs
)
-
1
]
require
.
NotNil
(
t
,
entry
)
require
.
Equal
(
t
,
"testsigclient"
,
entry
.
Request
.
GetRequestorName
())
//
require.Equal(t, "testsigclient", entry.Request.GetRequestorName())
require
.
NoError
(
t
,
err
)
sig
,
err
:=
entry
.
GetSignedMessage
()
require
.
NoError
(
t
,
err
)
...
...
irmaclient/logs.go
View file @
b836f687
package
irmaclient
import
(
"time"
"github.com/bwesterb/go-atum"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
)
...
...
@@ -15,7 +12,7 @@ type LogEntry struct {
Type
irma
.
Action
Time
irma
.
Timestamp
// Time at which the session was completed
Version
*
irma
.
ProtocolVersion
`json:",omitempty"`
// Protocol version that was used in the session
Request
irma
.
SessionRequest
`json:",omitempty"`
// Message that started the session
//
Request irma.SessionRequest `json:",omitempty"` // Message that started the session
// Session type-specific info
Removed
map
[
irma
.
CredentialTypeIdentifier
][]
irma
.
TranslatedString
`json:",omitempty"`
// In case of credential removal
...
...
@@ -30,68 +27,19 @@ const actionRemoval = irma.Action("removal")
// GetDisclosedCredentials gets the list of disclosed credentials for a log entry
func
(
entry
*
LogEntry
)
GetDisclosedCredentials
(
conf
*
irma
.
Configuration
)
([]
*
irma
.
DisclosedAttribute
,
error
)
{
if
entry
.
Type
==
actionRemoval
{
return
[]
*
irma
.
DisclosedAttribute
{},
nil
}
var
proofs
gabi
.
ProofList
disjunctions
:=
entry
.
Request
.
ToDisclose
()
if
entry
.
Type
==
irma
.
ActionIssuing
{
proofs
=
entry
.
IssueCommitment
.
Proofs
}
else
{
proofs
=
entry
.
ProofList
}
_
,
attrs
,
err
:=
irma
.
ProofList
(
proofs
)
.
DisclosedAttributes
(
conf
,
disjunctions
)
return
attrs
,
err
return
nil
,
nil
}
// GetIssuedCredentials gets the list of issued credentials for a log entry
func
(
entry
*
LogEntry
)
GetIssuedCredentials
(
conf
*
irma
.
Configuration
)
(
list
irma
.
CredentialInfoList
,
err
error
)
{
if
entry
.
Type
!=
irma
.
ActionIssuing
{
return
irma
.
CredentialInfoList
{},
nil
}
return
entry
.
Request
.
(
*
irma
.
IssuanceRequest
)
.
GetCredentialInfoList
(
conf
,
entry
.
Version
)
return
nil
,
nil
}
// GetSignedMessage gets the signed for a log entry
func
(
entry
*
LogEntry
)
GetSignedMessage
()
(
abs
*
irma
.
SignedMessage
,
err
error
)
{
if
entry
.
Type
!=
irma
.
ActionSigning
{
return
nil
,
nil
}
request
:=
entry
.
Request
.
(
*
irma
.
SignatureRequest
)
return
&
irma
.
SignedMessage
{
Signature
:
entry
.
ProofList
,
Nonce
:
request
.
Nonce
,
Context
:
request
.
Context
,
Message
:
string
(
entry
.
SignedMessage
),
Timestamp
:
entry
.
Timestamp
,
},
nil
return
nil
,
nil
}
func
(
session
*
session
)
createLogEntry
(
response
interface
{})
(
*
LogEntry
,
error
)
{
entry
:=
&
LogEntry
{
Type
:
session
.
Action
,
Time
:
irma
.
Timestamp
(
time
.
Now
()),
Version
:
session
.
Version
,
Request
:
session
.
request
,
}
switch
entry
.
Type
{
case
actionRemoval
:
case
irma
.
ActionSigning
:
// Get the signed message and timestamp
request
:=
session
.
request
.
(
*
irma
.
SignatureRequest
)
entry
.
SignedMessage
=
[]
byte
(
request
.
Message
)
entry
.
Timestamp
=
request
.
Timestamp
fallthrough
case
irma
.
ActionDisclosing
:
entry
.
ProofList
=
response
.
(
gabi
.
ProofList
)
case
irma
.
ActionIssuing
:
entry
.
IssueCommitment
=
response
.
(
*
gabi
.
IssueCommitmentMessage
)
default
:
return
nil
,
errors
.
New
(
"Invalid log type"
)
}
return
entry
,
nil
return
nil
,
nil
}
irmaclient/updates.go
View file @
b836f687
package
irmaclient
import
(
"encoding/json"
"math/big"
"regexp"
"os"
"time"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
)
...
...
@@ -72,85 +68,9 @@ var clientUpdates = []func(client *Client) error{
// 6: Guess and include version protocol in issuance logs, and convert log entry structure
// from Response to either IssueCommitment or ProofList
func
(
client
*
Client
)
(
err
error
)
{
logs
,
err
:=
client
.
Logs
()
if
err
!=
nil
{
return
}
// The logs read above do not contain the Response field as it has been removed from the LogEntry struct.
// So read the logs again into a slice of a temp struct that does contain this field.
type
oldLogEntry
struct
{
Response
json
.
RawMessage
SessionInfo
struct
{
Nonce
*
big
.
Int
`json:"nonce"`
Context
*
big
.
Int
`json:"context"`
Jwt
string
`json:"jwt"`
}
}
var
oldLogs
[]
*
oldLogEntry
if
err
=
client
.
storage
.
load
(
&
oldLogs
,
logsFile
);
err
!=
nil
{
return
}
// Sanity check, this should be true as both log slices were read from the same source
if
len
(
oldLogs
)
!=
len
(
logs
)
{
return
errors
.
New
(
"Log count does not match"
)
}
for
i
,
entry
:=
range
logs
{
oldEntry
:=
oldLogs
[
i
]
if
len
(
oldEntry
.
Response
)
==
0
{
return
errors
.
New
(
"Log entry had no Response field"
)
}
var
jwt
irma
.
RequestorJwt
jwt
,
err
=
irma
.
ParseRequestorJwt
(
entry
.
Type
,
oldEntry
.
SessionInfo
.
Jwt
)
if
err
!=
nil
{
return
err
}
entry
.
Request
=
jwt
.
SessionRequest
()
entry
.
Request
.
SetRequestorName
(
jwt
.
Requestor
())
entry
.
Request
.
SetNonce
(
oldEntry
.
SessionInfo
.
Nonce
)
entry
.
Request
.
SetContext
(
oldEntry
.
SessionInfo
.
Context
)
switch
entry
.
Type
{
case
actionRemoval
:
// nop
case
irma
.
ActionSigning
:
fallthrough
case
irma
.
ActionDisclosing
:
proofs
:=
[]
*
gabi
.
ProofD
{}
if
err
=
json
.
Unmarshal
(
oldEntry
.
Response
,
&
proofs
);
err
!=
nil
{
return
}
for
_
,
proof
:=
range
proofs
{
entry
.
ProofList
=
append
(
entry
.
ProofList
,
proof
)
}
case
irma
.
ActionIssuing
:
entry
.
IssueCommitment
=
&
gabi
.
IssueCommitmentMessage
{}
if
err
=
json
.
Unmarshal
(
oldEntry
.
Response
,
entry
.
IssueCommitment
);
err
!=
nil
{
return
err
}
default
:
return
errors
.
New
(
"Invalid log type"
)
}
if
entry
.
Type
!=
irma
.
ActionIssuing
{
continue
}
// Ugly hack alert: unfortunately the protocol version that was used in the session is nowhere recorded.
// This means that we cannot be sure whether or not we should byteshift the presence bit out of the attributes
// that was introduced in version 2.3 of the protocol. The only thing that I can think of to determine this
// is to check if the attributes are human-readable, i.e., alphanumeric: if the presence bit is present and
// we do not shift it away, then they almost certainly will not be.
for
_
,
attr
:=
range
entry
.
Request
.
(
*
irma
.
IssuanceRequest
)
.
Credentials
[
0
]
.
Attributes
{
if
regexp
.
MustCompile
(
"^
\\
w"
)
.
Match
([]
byte
(
attr
))
{
entry
.
Version
=
irma
.
NewVersion
(
2
,
2
)
}
else
{
entry
.
Version
=
irma
.
NewVersion
(
2
,
3
)
}
break
}
}
return
client
.
storage
.
StoreLogs
(
logs
)
// TODO: this has been temporarily removed and should be restored
os
.
Remove
(
client
.
storage
.
path
(
logsFile
))
return
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