Attempt at configuration

This commit is contained in:
Orion Poplawski
2023-06-02 17:13:20 -06:00
committed by Min RK
parent aae5aee065
commit 107b98b964
4 changed files with 39 additions and 1 deletions

View File

@@ -22,6 +22,21 @@ started.
If this configuration value is not set, then **all authenticated users will be allowed into your hub**. If this configuration value is not set, then **all authenticated users will be allowed into your hub**.
``` ```
## One Time Passwords ( request_otp )
By setting `request_otp` to true, the login screen will show and additional password input field
to accept an OTP:
```python
c.Authenticator.request_otp = True
```
By default, the prompt label is `OTP:`, but this can be changed by setting `otp_prompt`:
```python
c.Authenticator.otp_prompt = 'Google Authenticator:'
```
## Configure admins (`admin_users`) ## Configure admins (`admin_users`)
```{note} ```{note}

View File

@@ -157,6 +157,25 @@ class Authenticator(LoggingConfigurable):
""" """
).tag(config=True) ).tag(config=True)
otp_prompt = Any(
"OTP:",
help="""
The prompt string for the extra OTP (One Time Password) field. Defaults to `OTP:`.
.. versionadded:: 4.1
""",
).tag(config=True)
request_otp = Bool(
False,
config=True,
help="""
Display the extra OTP (One Time Password) prompt on the login scree.
.. versionadded:: 4.1
""",
)
_deprecated_aliases = { _deprecated_aliases = {
"whitelist": ("allowed_users", "1.2"), "whitelist": ("allowed_users", "1.2"),
"blacklist": ("blocked_users", "1.2"), "blacklist": ("blocked_users", "1.2"),

View File

@@ -105,6 +105,8 @@ class LoginHandler(BaseHandler):
'next': self.get_argument('next', ''), 'next': self.get_argument('next', ''),
}, },
), ),
"authenticator_request_otp": self.settings['request_otp'],
"authenticator_otp_prompt": self.settings['otp_prompt'],
"xsrf": self.xsrf_token.decode('ascii'), "xsrf": self.xsrf_token.decode('ascii'),
} }
custom_html = Template( custom_html = Template(

View File

@@ -64,7 +64,8 @@
id="password_input" id="password_input"
tabindex="2" tabindex="2"
/> />
<label for='otp_input'>OTP (if required):</label> {% if authenticator_request_otp %}
<label for='otp_input'>{{ authenticator_otp_prompt }}</label>
<input <input
type="password" type="password"
class="form-control" class="form-control"
@@ -73,6 +74,7 @@
id="otp_input" id="otp_input"
tabindex="3" tabindex="3"
/> />
{% endif %}
<div class="feedback-container"> <div class="feedback-container">
<input <input