Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
0a68de6c
Commit
0a68de6c
authored
4 years ago
by
Jeremy Lin
Browse files
Options
Downloads
Patches
Plain Diff
Warn on empty `ADMIN_TOKEN` instead of bailing out
The admin page will still be disabled. Fixes #849.
parent
77f95146
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/api/admin.rs
+1
-1
1 addition, 1 deletion
src/api/admin.rs
src/config.rs
+9
-1
9 additions, 1 deletion
src/config.rs
with
10 additions
and
2 deletions
src/api/admin.rs
+
1
−
1
View file @
0a68de6c
...
@@ -17,7 +17,7 @@ use crate::mail;
...
@@ -17,7 +17,7 @@ use crate::mail;
use
crate
::
CONFIG
;
use
crate
::
CONFIG
;
pub
fn
routes
()
->
Vec
<
Route
>
{
pub
fn
routes
()
->
Vec
<
Route
>
{
if
CONFIG
.admin_token
()
.is_none
()
&&
!
CONFIG
.
d
is
able
_admin_token
()
{
if
!
CONFIG
.
disable_
admin_token
()
&&
!
CONFIG
.is_admin_token
_set
()
{
return
routes!
[
admin_disabled
];
return
routes!
[
admin_disabled
];
}
}
...
...
This diff is collapsed.
Click to expand it.
src/config.rs
+
9
−
1
View file @
0a68de6c
...
@@ -430,7 +430,8 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
...
@@ -430,7 +430,8 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
if
let
Some
(
ref
token
)
=
cfg
.admin_token
{
if
let
Some
(
ref
token
)
=
cfg
.admin_token
{
if
token
.trim
()
.is_empty
()
&&
!
cfg
.disable_admin_token
{
if
token
.trim
()
.is_empty
()
&&
!
cfg
.disable_admin_token
{
err!
(
"`ADMIN_TOKEN` is enabled but has an empty value. To enable the admin page without token, use `DISABLE_ADMIN_TOKEN`"
)
println!
(
"[WARNING] `ADMIN_TOKEN` is enabled but has an empty value, so the admin page will be disabled."
);
println!
(
"[WARNING] To enable the admin page without a token, use `DISABLE_ADMIN_TOKEN`."
);
}
}
}
}
...
@@ -617,6 +618,13 @@ impl Config {
...
@@ -617,6 +618,13 @@ impl Config {
}
}
}
}
/// Tests whether the admin token is set to a non-empty value.
pub
fn
is_admin_token_set
(
&
self
)
->
bool
{
let
token
=
self
.admin_token
();
!
token
.is_none
()
&&
!
token
.unwrap
()
.trim
()
.is_empty
()
}
pub
fn
render_template
<
T
:
serde
::
ser
::
Serialize
>
(
pub
fn
render_template
<
T
:
serde
::
ser
::
Serialize
>
(
&
self
,
&
self
,
name
:
&
str
,
name
:
&
str
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment