Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
55082303
Commit
55082303
authored
Oct 19, 2020
by
Robert Czechowski
Browse files
Make dbstatus page optionally require a configured secret string
parent
f0deebc5
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/config.rs
View file @
55082303
...
@@ -36,6 +36,7 @@ pub struct Config {
...
@@ -36,6 +36,7 @@ pub struct Config {
pub
allow_sex_na
:
Option
<
bool
>
,
pub
allow_sex_na
:
Option
<
bool
>
,
pub
allow_sex_diverse
:
Option
<
bool
>
,
pub
allow_sex_diverse
:
Option
<
bool
>
,
pub
allow_sex_other
:
Option
<
bool
>
,
pub
allow_sex_other
:
Option
<
bool
>
,
pub
dbstatus_secret
:
Option
<
String
>
,
pub
template_params
:
Option
<
::
std
::
collections
::
BTreeMap
<
String
,
String
>>
,
pub
template_params
:
Option
<
::
std
::
collections
::
BTreeMap
<
String
,
String
>>
,
}
}
...
...
src/core.rs
View file @
55082303
...
@@ -152,7 +152,13 @@ pub fn show_login<T: MedalConnection>(conn: &T, session_token: Option<String>, l
...
@@ -152,7 +152,13 @@ pub fn show_login<T: MedalConnection>(conn: &T, session_token: Option<String>, l
(
"login"
.to_owned
(),
data
)
(
"login"
.to_owned
(),
data
)
}
}
pub
fn
status
<
T
:
MedalConnection
>
(
conn
:
&
T
,
_
:
())
->
String
{
conn
.get_debug_information
()
}
pub
fn
status
<
T
:
MedalConnection
>
(
conn
:
&
T
,
config_secret
:
Option
<
String
>
,
given_secret
:
Option
<
String
>
)
->
MedalResult
<
String
>
{
if
config_secret
==
given_secret
{
Ok
(
conn
.get_debug_information
())
}
else
{
Err
(
MedalError
::
AccessDenied
)
}
}
pub
fn
debug
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
Option
<
String
>
)
pub
fn
debug
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
Option
<
String
>
)
->
(
String
,
json_val
::
Map
<
String
,
json_val
::
Value
>
)
{
->
(
String
,
json_val
::
Map
<
String
,
json_val
::
Value
>
)
{
...
...
src/webfw_iron.rs
View file @
55082303
...
@@ -334,7 +334,11 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
...
@@ -334,7 +334,11 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
fn
dbstatus
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
fn
dbstatus
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
status
=
with_conn!
[
core
::
status
,
C
,
req
,
()];
let
config
=
req
.get
::
<
Read
<
SharedConfiguration
>>
()
.unwrap
();
let
query_string
=
req
.url
.query
()
.map
(|
s
|
s
.to_string
());
let
status
=
with_conn!
[
core
::
status
,
C
,
req
,
config
.dbstatus_secret
.clone
(),
query_string
]
.aug
(
req
)
?
;
let
mut
resp
=
Response
::
new
();
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
status
)
.set_mut
(
status
::
Ok
);
resp
.set_mut
(
status
)
.set_mut
(
status
::
Ok
);
...
...
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