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
28f39a1a
Commit
28f39a1a
authored
Mar 07, 2019
by
Sietse Ringers
Browse files
Disable server sent events by default
parent
19844154
Pipeline
#19772
failed with stages
in 2 minutes and 33 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
internal/servercore/api.go
View file @
28f39a1a
...
...
@@ -223,6 +223,10 @@ func ParsePath(path string) (string, string, error) {
}
func
(
s
*
Server
)
SubscribeServerSentEvents
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
token
string
,
requestor
bool
)
error
{
if
!
s
.
conf
.
EnableSSE
{
return
errors
.
New
(
"Server sent events disabled"
)
}
var
session
*
session
if
requestor
{
session
=
s
.
sessions
.
get
(
token
)
...
...
server/api.go
View file @
28f39a1a
...
...
@@ -47,6 +47,8 @@ type Configuration struct {
// See https://github.com/privacybydesign/irmago/tree/master/server#specifying-an-email-address
// for more information
Email
string
`json:"email" mapstructure:"email"`
// Enable server sent events for status updates (experimental; tends to hang when a reverse proxy is used)
EnableSSE
bool
}
type
SessionPackage
struct
{
...
...
server/irmad/cmd/root.go
View file @
28f39a1a
...
...
@@ -83,6 +83,7 @@ func setFlags(cmd *cobra.Command) error {
flags
.
String
(
"static-path"
,
""
,
"Host files under this path as static files (leave empty to disable)"
)
flags
.
String
(
"static-prefix"
,
"/"
,
"Host static files under this URL prefix"
)
flags
.
StringP
(
"url"
,
"u"
,
defaulturl
,
"external URL to server to which the IRMA client connects"
)
flags
.
Bool
(
"sse"
,
false
,
"Enable server sent for status updates (experimental)"
)
flags
.
IntP
(
"port"
,
"p"
,
8088
,
"port at which to listen"
)
flags
.
StringP
(
"listen-addr"
,
"l"
,
""
,
"address at which to listen (default 0.0.0.0)"
)
...
...
@@ -185,9 +186,10 @@ func configure(cmd *cobra.Command) error {
SchemesUpdateInterval
:
viper
.
GetInt
(
"schemes-update"
),
DisableSchemesUpdate
:
viper
.
GetInt
(
"schemes-update"
)
==
0
,
IssuerPrivateKeysPath
:
viper
.
GetString
(
"privkeys"
),
URL
:
viper
.
GetString
(
"url"
),
Email
:
viper
.
GetString
(
"email"
),
Logger
:
logger
,
URL
:
viper
.
GetString
(
"url"
),
Email
:
viper
.
GetString
(
"email"
),
EnableSSE
:
viper
.
GetBool
(
"sse"
),
Logger
:
logger
,
},
Permissions
:
requestorserver
.
Permissions
{
Disclosing
:
handlePermission
(
"disclose-perms"
),
...
...
server/irmaserver/main.go
View file @
28f39a1a
...
...
@@ -129,7 +129,11 @@ func (s *Server) HandlerFunc() http.HandlerFunc {
token
,
noun
,
err
:=
servercore
.
ParsePath
(
r
.
URL
.
Path
)
if
err
==
nil
&&
noun
==
"statusevents"
{
// if err != nil we let it be handled by HandleProtocolMessage below
if
err
=
s
.
SubscribeServerSentEvents
(
w
,
r
,
token
,
false
);
err
!=
nil
{
server
.
WriteError
(
w
,
server
.
ErrorUnexpectedRequest
,
err
.
Error
())
server
.
WriteResponse
(
w
,
nil
,
&
irma
.
RemoteError
{
Status
:
server
.
ErrorUnsupported
.
Status
,
ErrorName
:
string
(
server
.
ErrorUnsupported
.
Type
),
Description
:
server
.
ErrorUnsupported
.
Description
,
})
}
return
}
...
...
server/requestorserver/server.go
View file @
28f39a1a
...
...
@@ -295,7 +295,11 @@ func (s *Server) handleStatusEvents(w http.ResponseWriter, r *http.Request) {
token
:=
chi
.
URLParam
(
r
,
"token"
)
s
.
conf
.
Logger
.
WithFields
(
logrus
.
Fields
{
"session"
:
token
})
.
Debug
(
"new client subscribed to server sent events"
)
if
err
:=
s
.
irmaserv
.
SubscribeServerSentEvents
(
w
,
r
,
token
,
true
);
err
!=
nil
{
server
.
WriteError
(
w
,
server
.
ErrorUnexpectedRequest
,
err
.
Error
())
server
.
WriteResponse
(
w
,
nil
,
&
irma
.
RemoteError
{
Status
:
server
.
ErrorUnsupported
.
Status
,
ErrorName
:
string
(
server
.
ErrorUnsupported
.
Type
),
Description
:
server
.
ErrorUnsupported
.
Description
,
})
}
}
...
...
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