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
1a28bc08
Commit
1a28bc08
authored
Aug 13, 2018
by
Sietse Ringers
Browse files
Properly handle timeouts
parent
161d2d0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
irmaserver/api.go
View file @
1a28bc08
...
...
@@ -23,11 +23,13 @@ type SessionResult struct {
Err
*
irma
.
RemoteError
}
// Status is the status of an IRMA session.
type
Status
string
const
(
StatusInitialized
Status
=
"INITIALIZED"
StatusConnected
Status
=
"CONNECTED"
StatusCancelled
Status
=
"CANCELLED"
StatusDone
Status
=
"DONE"
StatusInitialized
Status
=
"INITIALIZED"
// The session has been started and is waiting for the client
StatusConnected
Status
=
"CONNECTED"
// The client has retrieved the session request, we wait for its response
StatusCancelled
Status
=
"CANCELLED"
// The session is cancelled, possibly due to an error
StatusDone
Status
=
"DONE"
// The session has completed successfully
StatusTimeout
Status
=
"TIMEOUT"
// Session timed out
)
irmaserver/backend/helpers.go
View file @
1a28bc08
...
...
@@ -18,7 +18,9 @@ import (
// Session helpers
func
(
session
*
session
)
finished
()
bool
{
return
session
.
status
==
irmaserver
.
StatusDone
||
session
.
status
==
irmaserver
.
StatusCancelled
return
session
.
status
==
irmaserver
.
StatusDone
||
session
.
status
==
irmaserver
.
StatusCancelled
||
session
.
status
==
irmaserver
.
StatusTimeout
}
func
(
session
*
session
)
markAlive
()
{
...
...
irmaserver/backend/sessions.go
View file @
1a28bc08
...
...
@@ -77,8 +77,14 @@ func (s memorySessionStore) deleteExpired() {
expired
:=
make
([]
string
,
0
,
len
(
s
.
m
))
for
token
,
session
:=
range
s
.
m
{
if
session
.
lastActive
.
Add
(
5
*
time
.
Minute
)
.
Before
(
time
.
Now
())
{
conf
.
Logger
.
Infof
(
"Session %s expired, deleting"
,
token
)
expired
=
append
(
expired
,
token
)
if
!
session
.
finished
()
{
conf
.
Logger
.
Infof
(
"Session %s expired"
,
token
)
session
.
markAlive
()
session
.
setStatus
(
irmaserver
.
StatusTimeout
)
}
else
{
conf
.
Logger
.
Infof
(
"Deleting %s"
,
token
)
expired
=
append
(
expired
,
token
)
}
}
}
s
.
RUnlock
()
...
...
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