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
d27ed345
Commit
d27ed345
authored
Aug 13, 2018
by
Sietse Ringers
Browse files
Remove frontend session store
Co-authored-by:
Confiks
<
confiks@scriptbase.org
>
parent
5180c461
Changes
5
Hide whitespace changes
Inline
Side-by-side
irmaserver/api.go
View file @
d27ed345
...
...
@@ -15,11 +15,12 @@ type Configuration struct {
}
type
SessionResult
struct
{
Token
string
Status
irma
.
ProofStatus
Disclosed
[]
*
irma
.
DisclosedAttribute
Signature
*
irma
.
SignedMessage
Err
*
irma
.
RemoteError
Token
string
Status
Status
ProofStatus
irma
.
ProofStatus
Disclosed
[]
*
irma
.
DisclosedAttribute
Signature
*
irma
.
SignedMessage
Err
*
irma
.
RemoteError
}
type
Status
string
...
...
irmaserver/backend/api.go
View file @
d27ed345
...
...
@@ -63,6 +63,14 @@ func StartSession(request irma.SessionRequest) (*irma.Qr, string, error) {
},
session
.
token
,
nil
}
func
GetSessionResult
(
token
string
)
*
irmaserver
.
SessionResult
{
session
:=
sessions
.
get
(
token
)
if
session
!=
nil
{
return
nil
}
return
session
.
result
}
func
HandleProtocolMessage
(
path
string
,
method
string
,
...
...
irmaserver/backend/handle.go
View file @
d27ed345
...
...
@@ -19,8 +19,7 @@ func (session *session) handleDelete() {
}
session
.
markAlive
()
// TODO const ProofStatusCancelled = irma.ProofStatus("CANCELLED") ?
session
.
result
=
&
irmaserver
.
SessionResult
{
Token
:
session
.
token
}
session
.
result
=
&
irmaserver
.
SessionResult
{
Token
:
session
.
token
,
Status
:
irmaserver
.
StatusCancelled
}
session
.
setStatus
(
irmaserver
.
StatusCancelled
)
}
...
...
@@ -47,10 +46,10 @@ func (session *session) handlePostSignature(signature *irma.SignedMessage) (*irm
session
.
markAlive
()
session
.
result
.
Signature
=
signature
session
.
result
.
Disclosed
,
session
.
result
.
Status
=
signature
.
Verify
(
session
.
result
.
Disclosed
,
session
.
result
.
Proof
Status
=
signature
.
Verify
(
conf
.
IrmaConfiguration
,
session
.
request
.
(
*
irma
.
SignatureRequest
))
session
.
setStatus
(
irmaserver
.
StatusDone
)
return
&
session
.
result
.
Status
,
nil
return
&
session
.
result
.
Proof
Status
,
nil
}
func
(
session
*
session
)
handlePostProofs
(
proofs
gabi
.
ProofList
)
(
*
irma
.
ProofStatus
,
*
irma
.
RemoteError
)
{
...
...
@@ -59,10 +58,10 @@ func (session *session) handlePostProofs(proofs gabi.ProofList) (*irma.ProofStat
}
session
.
markAlive
()
session
.
result
.
Disclosed
,
session
.
result
.
Status
=
irma
.
ProofList
(
proofs
)
.
Verify
(
session
.
result
.
Disclosed
,
session
.
result
.
Proof
Status
=
irma
.
ProofList
(
proofs
)
.
Verify
(
conf
.
IrmaConfiguration
,
session
.
request
.
(
*
irma
.
DisclosureRequest
))
session
.
setStatus
(
irmaserver
.
StatusDone
)
return
&
session
.
result
.
Status
,
nil
return
&
session
.
result
.
Proof
Status
,
nil
}
func
(
session
*
session
)
handlePostCommitments
(
commitments
*
gabi
.
IssueCommitmentMessage
)
([]
*
gabi
.
IssueSignatureMessage
,
*
irma
.
RemoteError
)
{
...
...
@@ -103,9 +102,9 @@ func (session *session) handlePostCommitments(commitments *gabi.IssueCommitmentM
}
// Verify all proofs and check disclosed attributes, if any, against request
session
.
result
.
Disclosed
,
session
.
result
.
Status
=
irma
.
ProofList
(
commitments
.
Proofs
)
.
VerifyAgainstDisjunctions
(
session
.
result
.
Disclosed
,
session
.
result
.
Proof
Status
=
irma
.
ProofList
(
commitments
.
Proofs
)
.
VerifyAgainstDisjunctions
(
conf
.
IrmaConfiguration
,
request
.
Disclose
,
request
.
Context
,
request
.
Nonce
,
pubkeys
,
false
)
if
session
.
result
.
Status
!=
irma
.
ProofStatusValid
{
if
session
.
result
.
Proof
Status
!=
irma
.
ProofStatusValid
{
return
nil
,
session
.
fail
(
irmaserver
.
ErrorInvalidProofs
,
""
)
}
...
...
irmaserver/backend/helpers.go
View file @
d27ed345
...
...
@@ -27,12 +27,13 @@ func (session *session) markAlive() {
func
(
session
*
session
)
setStatus
(
status
irmaserver
.
Status
)
{
session
.
status
=
status
session
.
result
.
Status
=
status
}
func
(
session
*
session
)
fail
(
err
irmaserver
.
Error
,
message
string
)
*
irma
.
RemoteError
{
rerr
:=
getError
(
err
,
message
)
session
.
setStatus
(
irmaserver
.
StatusCancelled
)
session
.
result
=
&
irmaserver
.
SessionResult
{
Err
:
rerr
,
Token
:
session
.
token
}
session
.
result
=
&
irmaserver
.
SessionResult
{
Err
:
rerr
,
Token
:
session
.
token
,
Status
:
irmaserver
.
StatusCancelled
}
return
rerr
}
...
...
irmaserver/irmarequestor/main.go
View file @
d27ed345
...
...
@@ -3,7 +3,6 @@ package irmarequestor
import
(
"io/ioutil"
"net/http"
"sync"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/irmaserver"
...
...
@@ -12,43 +11,27 @@ import (
type
SessionHandler
func
(
*
irmaserver
.
SessionResult
)
type
SessionStore
interface
{
Get
(
token
string
)
*
irmaserver
.
SessionResult
Add
(
token
string
,
result
*
irmaserver
.
SessionResult
)
GetHandler
(
token
string
)
SessionHandler
SetHandler
(
token
string
,
handler
SessionHandler
)
SupportHandlers
()
bool
}
var
Sessions
SessionStore
=
&
MemorySessionStore
{
m
:
make
(
map
[
string
]
*
irmaserver
.
SessionResult
),
h
:
make
(
map
[
string
]
SessionHandler
),
}
type
MemorySessionStore
struct
{
sync
.
RWMutex
m
map
[
string
]
*
irmaserver
.
SessionResult
h
map
[
string
]
SessionHandler
}
var
handlers
=
make
(
map
[
string
]
SessionHandler
)
func
Initialize
(
configuration
*
irmaserver
.
Configuration
)
error
{
return
backend
.
Initialize
(
configuration
)
}
func
StartSession
(
request
irma
.
SessionRequest
,
handler
SessionHandler
)
(
*
irma
.
Qr
,
string
,
error
)
{
if
handler
!=
nil
&&
!
Sessions
.
SupportHandlers
()
{
panic
(
"Handlers not supported"
)
}
qr
,
token
,
err
:=
backend
.
StartSession
(
request
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
if
handler
!=
nil
{
Sessions
.
SetH
andler
(
token
,
handler
)
h
andler
s
[
token
]
=
handler
}
return
qr
,
token
,
nil
}
func
GetSessionResult
(
token
string
)
*
irmaserver
.
SessionResult
{
return
backend
.
GetSessionResult
(
token
)
}
func
HttpHandlerFunc
(
prefix
string
)
http
.
HandlerFunc
{
if
len
(
prefix
)
!=
0
&&
prefix
[
0
]
!=
'/'
{
prefix
=
"/"
+
prefix
...
...
@@ -65,39 +48,9 @@ func HttpHandlerFunc(prefix string) http.HandlerFunc {
w
.
WriteHeader
(
status
)
w
.
Write
(
response
)
if
result
!=
nil
{
Sessions
.
Add
(
result
.
Token
,
result
)
if
handler
:=
Sessions
.
GetHandler
(
result
.
Token
);
handler
!=
nil
{
if
handler
,
ok
:=
handlers
[
result
.
Token
];
ok
{
go
handler
(
result
)
}
}
}
}
func
(
s
MemorySessionStore
)
Get
(
token
string
)
*
irmaserver
.
SessionResult
{
s
.
RLock
()
defer
s
.
RUnlock
()
return
s
.
m
[
token
]
}
func
(
s
MemorySessionStore
)
Add
(
token
string
,
result
*
irmaserver
.
SessionResult
)
{
s
.
Lock
()
defer
s
.
Unlock
()
if
_
,
contains
:=
s
.
m
[
token
];
contains
{
return
}
s
.
m
[
token
]
=
result
}
func
(
s
MemorySessionStore
)
GetHandler
(
token
string
)
SessionHandler
{
s
.
RLock
()
defer
s
.
RUnlock
()
return
s
.
h
[
token
]
}
func
(
s
MemorySessionStore
)
SetHandler
(
token
string
,
handler
SessionHandler
)
{
s
.
Lock
()
defer
s
.
Unlock
()
s
.
h
[
token
]
=
handler
}
func
(
s
MemorySessionStore
)
SupportHandlers
()
bool
{
return
true
}
Write
Preview
Supports
Markdown
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