diff --git a/.gitignore b/.gitignore index e7965b8..0fd228f 100644 --- a/.gitignore +++ b/.gitignore @@ -56,11 +56,14 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* +# Ignore local config files +config/ + # Ignore Grunt.js dependencies node_modules/ # Ignore compiled CSS and JS -public/css/ +public/styles/ public/js/ # SASS compilation cache diff --git a/Gemfile b/Gemfile index 1b20c5f..e3778e1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ gem 'puma', '~> 6.0' gem 'rerun' +gem 'net-ldap', '~> 0.17' diff --git a/Gemfile.lock b/Gemfile.lock index 198d57c..bd82b46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.10) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) + net-ldap (0.17.1) nio4r (2.5.8) puma (6.0.0) nio4r (~> 2.0) @@ -30,6 +31,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + net-ldap (~> 0.17) puma (~> 6.0) rerun sinatra (~> 3.0) diff --git a/app/controllers/auth.rb b/app/controllers/auth.rb index 9f8f930..5ce957e 100644 --- a/app/controllers/auth.rb +++ b/app/controllers/auth.rb @@ -6,4 +6,21 @@ class AuthController < Sinatra::Base } end + post '/login' do + ldap = Net::LDAP.new + ldap.host = cnf['ldap']['server_url'] + ldap.port = 389 + ldap.auth(params[:login_username], params[:login_password]) + if ldap.bind() + session['ldap_uid'] = params[:username] + redirect '/account/view' + else + # Authentication failure + erb :'auth/login', :locals => { + :title => 'Login to your account', + :fail => true + } + end + end + end diff --git a/app/models/account.rb b/app/models/account.rb new file mode 100644 index 0000000..e69de29 diff --git a/assets/sass/darkmeyer.sass b/assets/sass/darkmeyer.sass index 048a8fc..2693926 100644 --- a/assets/sass/darkmeyer.sass +++ b/assets/sass/darkmeyer.sass @@ -1,4 +1,15 @@ +$primary-color: #009688 +$primary-color-highlight: lighten($primary-color, 10%) +$accent-color: #795548 +$accent-color-highlight: lighten($accent-color, 10%) + +$box-shadow-1: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23) +$box-shadow-2: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23) + +$nav-height: 60px + body + padding-top: $nav-height background: lightgrey #main-nav @@ -6,8 +17,9 @@ body top: 0 left: 0 width: 100% - height: 60px + height: $nav-height background: #212121 + box-shadow: $box-shadow-1 clear: float .nav-left @@ -21,3 +33,21 @@ body li display: inline-block + color: white + font-size: 2rem + &:first-child + margin-left: 20px + a + display: block + box-sizing: border-box + height: $nav-height + padding: 12px 15px + font-size: 2rem + +#main-wrapper + margin-top: 25px + padding: 20px 28px + background: white + border-radius: 5px + box-shadow: $box-shadow-2 + diff --git a/config.ru b/config.ru index 329bce9..87155f2 100644 --- a/config.ru +++ b/config.ru @@ -1,8 +1,15 @@ require 'rubygems' require 'sinatra/base' +require 'yaml' require_relative 'app/settings.rb' +defaultCnf = YAML::load_file(File.join(__dir__, 'config/defaults.yaml')) +cnf = YAML::load_file(File.join(__dir__, 'config/local.yaml')) +cnf = defaultCnf.merge(cnf) + +require 'net/ldap' + require_relative 'app/controllers/index.rb' require_relative 'app/controllers/auth.rb' diff --git a/public/styles/darkmeyer.css b/public/styles/darkmeyer.css deleted file mode 100644 index 102df10..0000000 --- a/public/styles/darkmeyer.css +++ /dev/null @@ -1,2 +0,0 @@ -body{background:#d3d3d3}#main-nav{position:fixed;top:0;left:0;width:100%;height:60px;background:#212121;clear:float}#main-nav .nav-left{float:left}#main-nav .nav-right{float:right}#main-nav .nav-menu ul{list-style:none}#main-nav .nav-menu li{display:inline-block} -/*# sourceMappingURL=darkmeyer.css.map */ diff --git a/public/styles/darkmeyer.css.map b/public/styles/darkmeyer.css.map deleted file mode 100644 index 038c480..0000000 --- a/public/styles/darkmeyer.css.map +++ /dev/null @@ -1,7 +0,0 @@ -{ -"version": 3, -"mappings": "AAAA,IAAI,CACF,UAAU,CAAE,OAAS,CAEvB,SAAS,CACP,QAAQ,CAAE,KAAK,CACf,GAAG,CAAE,CAAC,CACN,IAAI,CAAE,CAAC,CACP,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,OAAO,CACnB,KAAK,CAAE,KAAK,CAEZ,mBAAS,CACP,KAAK,CAAE,IAAI,CACb,oBAAU,CACR,KAAK,CAAE,KAAK,CAGZ,sBAAE,CACA,UAAU,CAAE,IAAI,CAElB,sBAAE,CACA,OAAO,CAAE,YAAY", -"sources": ["../../assets/sass/darkmeyer.sass"], -"names": [], -"file": "darkmeyer.css" -} diff --git a/views/account/view.erb b/views/account/view.erb new file mode 100644 index 0000000..f9d24a4 --- /dev/null +++ b/views/account/view.erb @@ -0,0 +1,11 @@ +
+
+ +
+
diff --git a/views/auth/login.erb b/views/auth/login.erb index f991480..060c275 100644 --- a/views/auth/login.erb +++ b/views/auth/login.erb @@ -14,7 +14,7 @@

- +
diff --git a/views/index.erb b/views/index.erb index 8b8f6f1..a0682a4 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,6 +1,8 @@

Welcome to Webdap!

-

You can use this site to manage your network account. Click here to login.

+

You can use this site to manage your network account.

+ +

Click here to login.

diff --git a/views/layout.erb b/views/layout.erb index c13ebcf..65943e4 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -6,6 +6,7 @@ <%= title %> | Webdap +