.circleci
.dependabot
.github
app
bin
config
db
dist
lib
assets
chewy
devise
two_factor_ldap_authenticatable.rb
two_factor_pam_authenticatable.rb
generators
json_ld
mastodon
paperclip
tasks
templates
cli.rb
log
nanobox
public
spec
streaming
vendor
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.js
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.profile
.rspec
.rubocop.yml
.ruby-version
.sass-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
babel.config.js
boxfile.yml
config.ru
crowdin.yml
docker-compose.yml
ide-helper.js
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
33 lines
741 B
Ruby
33 lines
741 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'net/ldap'
|
|
require 'devise/strategies/base'
|
|
|
|
module Devise
|
|
module Strategies
|
|
class TwoFactorLdapAuthenticatable < Base
|
|
def valid?
|
|
valid_params? && mapping.to.respond_to?(:authenticate_with_ldap)
|
|
end
|
|
|
|
def authenticate!
|
|
resource = mapping.to.authenticate_with_ldap(params[scope])
|
|
|
|
if resource && !resource.otp_required_for_login?
|
|
success!(resource)
|
|
else
|
|
fail(:invalid)
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def valid_params?
|
|
params[scope] && params[scope][:password].present?
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Warden::Strategies.add(:two_factor_ldap_authenticatable, Devise::Strategies::TwoFactorLdapAuthenticatable)
|