Fixed authentication; fixed configuration loading
This commit is contained in:
parent
72bb25a6ad
commit
980728bb07
@ -13,12 +13,11 @@ class Webdap
|
|||||||
end
|
end
|
||||||
|
|
||||||
post '/login' do
|
post '/login' do
|
||||||
ldap = Net::LDAP.new
|
ldap = Net::LDAP.new(:host => $conf.get('ldap.server_url'), :port => 389)
|
||||||
ldap.host = cnf['ldap']['server_url']
|
ldap_bind_dn = "#{$conf.get('ldap.user_uid_attr')}=#{params[:auth_username]},#{$conf.get('ldap.user_ou')}"
|
||||||
ldap.port = 389
|
|
||||||
ldap.auth(params[:login_username], params[:login_password])
|
if ldap.bind(:method => :simple, :username => ldap_bind_dn, :password => params[:auth_password])
|
||||||
if ldap.bind()
|
session['ldap_uid'] = params[:auth_username]
|
||||||
session['ldap_uid'] = params[:username]
|
|
||||||
redirect '/account/view'
|
redirect '/account/view'
|
||||||
else
|
else
|
||||||
# Authentication failure
|
# Authentication failure
|
||||||
|
@ -7,6 +7,7 @@ class Webdap
|
|||||||
get '/' do
|
get '/' do
|
||||||
erb :index, locals: {
|
erb :index, locals: {
|
||||||
title: 'Home',
|
title: 'Home',
|
||||||
|
server: $conf.get('ldap.server_url'),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
ldap:
|
ldap:
|
||||||
server_url: 'ldap://ldap.example.com'
|
server_url: 'ldap://ldap.example.com'
|
||||||
port: 389
|
port: 389
|
||||||
|
user_uid_attr: 'uid'
|
||||||
|
user_ou: 'ou=People,dc=example,dc=com'
|
||||||
|
|
||||||
server:
|
server:
|
||||||
address: '127.0.0.1'
|
address: '127.0.0.1'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Load application config
|
# Load application config
|
||||||
require './app/config.rb'
|
require './app/config.rb'
|
||||||
$conf = Config.new(File.join(__dir__, 'config/config.yaml'))
|
$conf = Config.new(File.join(__dir__, '../config/config.yaml'))
|
||||||
|
|
||||||
bind_address = "tcp://#{$conf.get('server.address')}:#{$conf.get('server.port')}"
|
bind_address = "tcp://#{$conf.get('server.address')}:#{$conf.get('server.port')}"
|
||||||
bind bind_address
|
bind bind_address
|
||||||
|
@ -4,5 +4,7 @@
|
|||||||
<p>You can use this site to manage your network account. <i class="fa-solid fa-address-book"></i></p>
|
<p>You can use this site to manage your network account. <i class="fa-solid fa-address-book"></i></p>
|
||||||
|
|
||||||
<p><a href="/auth/login">Click here</a> to login.</p>
|
<p><a href="/auth/login">Click here</a> to login.</p>
|
||||||
|
|
||||||
|
<p>Server URL: <%= server %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user