gatepass 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6adfbc31cccc12d1786457c468667bcba579db0db4639aae68a01bb61a570e64
4
- data.tar.gz: 5e456e23ddcda822bc391601c88fb0286184abc9f164de6ad2cf35e1765b912d
3
+ metadata.gz: 6e7aeabfb6de154ecf1aa96f4e9009137eb8e9c674c3a8be94f4eddce9880945
4
+ data.tar.gz: ca35a4b1f36f2f943b4dcbebfcbfce21c698a7f173bce1f991038e48d273958d
5
5
  SHA512:
6
- metadata.gz: 10d45f2705514fbd230e72a336f13935e88d571b55d76431c1acedb942f47c34b84cb352c55c442842fe1df00d08641b21ac02444ded243149aba3a77f20e0c9
7
- data.tar.gz: 200c1bf025039c8e889951d30afe355dc8b010087c8e66526d854ff38438887b6cb329ccefdb00f063baf4e3f5d4017346b45ba564160890ffc2b3e78a954304
6
+ metadata.gz: 877b3867d4b2e5d565d2ea57ccc367ba368c62a17afd6aa98db3fa5aedbf91d3879c3bacd220da4af11feeae82ae1212cc27ad521984d17ee38f6f6ab2785e86
7
+ data.tar.gz: 754407cd8631ac1f502d766a1939d6fbba4e387817c8335584740b196f8572cdfe13f0c0af456d3ccf9a9d8785f6e2ba559d5740da01c835b3b9d021967dad1a
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  Short description and motivation.
3
3
 
4
4
  ## Usage
5
- How to use my plugin.
5
+ See the Installation section below.
6
6
 
7
7
  ## Installation
8
8
  Add this line to your application's Gemfile:
@@ -21,6 +21,12 @@ Or install it yourself as:
21
21
  $ gem install gatepass
22
22
  ```
23
23
 
24
+ Mount the engine with the following line in `config/routes.rb` :
25
+ ```
26
+ mount Gatepass::Engine => '/gatepass'
27
+ ```
28
+ Ensure you also have the root configured (Eg. `root 'home#index''`) for your Rails application.
29
+
24
30
  Modify the application controller to include the Gatepass module and add the authentication check:
25
31
  ```
26
32
  class ApplicationController < ActionController::Base
@@ -29,7 +35,19 @@ class ApplicationController < ActionController::Base
29
35
  end
30
36
  ```
31
37
 
32
- TODO - Configuration parameters
38
+ In `config/application.rb` , define the following configuration parameters:
39
+ ```
40
+ config.ldap_server_hostname = 'myldap.com'
41
+ config.ldap_server_port = 636
42
+ config.ldap_ca_cert = '/etc/path/ca.cert'
43
+ config.ldap_base = 'DN=myldap,DN=com'
44
+ ```
45
+
46
+ Run the migrations with:
47
+ ```
48
+ rails gatepass:install:migrations
49
+ rails db:migrate
50
+ ```
33
51
 
34
52
  Create an initial user account with:
35
53
  ```
@@ -52,7 +70,7 @@ auth_type is `local` or `activedirectory`.
52
70
  Use a dummy password for activedirectory users.
53
71
 
54
72
  ## Contributing
55
- Contribution directions go here.
73
+ Create a pull request on GitHub.
56
74
 
57
75
  ## License
58
76
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,13 +1,17 @@
1
1
  module Gatepass
2
+ # Provides the login/logout functionality
2
3
  class AuthenticationController < ApplicationController
4
+ # Display the login form
3
5
  def login
4
6
  end
5
7
 
8
+ # Remove the user from the session and redirect to the login form
6
9
  def logout
7
10
  session.delete :user
8
11
  redirect_to :action => :login
9
12
  end
10
13
 
14
+ # Process the POST from the login form
11
15
  def authenticate
12
16
  username = params[:username]
13
17
  password = params[:password]
@@ -25,7 +29,7 @@ module Gatepass
25
29
  elsif user.auth_type == 'activedirectory' # 'ldap'
26
30
  require 'net/ldap'
27
31
 
28
- server_address = Rails.application.config.ldap_server_hostname # 'ad.nitinkatkam.mdbrecruit.net'
32
+ server_address = Rails.application.config.ldap_server_hostname
29
33
  server_port = Rails.application.config.ldap_server_port
30
34
  ca_certificate = Rails.application.config.ldap_ca_cert
31
35
 
@@ -34,7 +38,7 @@ module Gatepass
34
38
  :encryption => {
35
39
  method: :simple_tls,
36
40
  tls_options: {
37
- ca_file: ca_certificate # '/Users/nitin.katkam/Downloads/nitinkatkam-ad-ca.cer',
41
+ ca_file: ca_certificate
38
42
  # verify_mode: OpenSSL::SSL::VERIFY_NONE
39
43
  }
40
44
  },
@@ -45,18 +49,16 @@ module Gatepass
45
49
  }
46
50
 
47
51
  filter = Net::LDAP::Filter.eq("distinguishedname", user.username_mapping)
48
- treebase = Rails.application.config.ldap_base # "dc=nitinkatkam, dc=mdbrecruit, dc=net"
52
+ treebase = Rails.application.config.ldap_base
49
53
 
50
54
  search_result_count = 0
51
55
  ldap.search(:base => treebase, :filter => filter) do |entry|
52
56
  search_result_count += 1
53
- # puts "DN: #{entry.dn}" # CN=bindUser1,CN=Users,DC=nitinkatkam,DC=mdbrecruit,DC=net
54
- # puts "memberOf: #{entry.memberof}" #["CN=peopleOfNitinKatkam,CN=Users,DC=nitinkatkam,DC=mdbrecruit,DC=net", "CN=Administrators,CN=Builtin,DC=nitinkatkam,DC=mdbrecruit,DC=net"]
55
57
 
56
58
  if ldap.get_operation_result.code == 49 or search_result_count == 0
57
59
  redirect_to({ controller: 'gatepass/authentication', action: 'login' })
58
60
  elsif search_result_count == 1
59
- session[:user] = user # entry # user_obj
61
+ session[:user] = user # entry
60
62
  redirect_to main_app.root_url
61
63
  else
62
64
  redirect_to({ controller: 'gatepass/authentication', action: 'login' })
@@ -1,3 +1,3 @@
1
1
  module Gatepass
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/gatepass.rb CHANGED
@@ -2,9 +2,10 @@ require "gatepass/version"
2
2
  require "gatepass/engine"
3
3
 
4
4
  module Gatepass
5
+ # Check if the user is defined in the session; if not, redirects to the login page
5
6
  def check_authenticated
6
7
  if session[:user].nil?
7
- redirect_to user_auth.authentication_login_path ({ :controller => 'gatepass/authentication', :action => :login })
8
+ redirect_to gatepass.authentication_login_path ({ :controller => 'gatepass/authentication', :action => :login })
8
9
  end
9
10
  end
10
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gatepass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nitin Reddy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-26 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.1.19
41
+ - !ruby/object:Gem::Dependency
42
+ name: net-ldap
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.18.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.18.0
41
55
  description: This Rails plugin enables you to authenticate users against the local
42
56
  database as well as against an ActiveDirectory server
43
57
  email:
@@ -77,9 +91,11 @@ files:
77
91
  - lib/gatepass/engine.rb
78
92
  - lib/gatepass/version.rb
79
93
  - lib/tasks/gatepass_tasks.rake
80
- homepage:
94
+ homepage: https://github.com/pockettheories/gatepass
81
95
  licenses: []
82
- metadata: {}
96
+ metadata:
97
+ homepage_uri: https://github.com/pockettheories/gatepass
98
+ source_code_uri: https://github.com/pockettheories/gatepass
83
99
  post_install_message:
84
100
  rdoc_options: []
85
101
  require_paths: