Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a list of password tokens #61

Open
wants to merge 2 commits into
base: multi-domain
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/domains/default.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ module.exports = {
// Simple password login, make sure you choose a very secure password.
// password: {
// token: "YOUR-PASSWORD" // any user that knows this can log in
// -- or --
// tokens: ["ONE-PASSWORD", "ANOTHER-PASSWORD"] // either of these can be used
// },

// Register a new oauth app on Google Apps at
Expand Down
8 changes: 3 additions & 5 deletions lib/proxy_domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ class ProxyDomain {
passport.use(
`${this.options.domain}-local`,
new LocalStrategy({ tokenField: "password" }, function(token, cb) {
if (
config.token &&
config.token.length === token.length &&
safeCompare(config.token, token)
) {
const tokens = config.token ? [config.token] : config.tokens || [];

if (tokens.find(t => t.length && t.length == token.length && safeCompare(t, token))) {
log.info("Authenticated with password login");
return cb(null, { password: { authenticated: true } });
} else {
Expand Down