blueauth 0.0.16 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b0cb18fd2b7ec0999979c82b4785d1174aff330
4
- data.tar.gz: 5dc410f009472d66bad111b10824987185e8e636
3
+ metadata.gz: 8165645faa29f6da46652f30a954374db6a58b1d
4
+ data.tar.gz: 1c8f22b04657dfdf1e67560ba22995a3b87f696a
5
5
  SHA512:
6
- metadata.gz: 42b3b6c06fae02b74e903b3c8feada2d5fd7c00ee8c7915d6a66dfaef46054a13a55285fada60f234b1e660622337e9c206cd7b9c837d7e7e1e7b75a22ed1eaa
7
- data.tar.gz: 7fc0b7b5c913ef096300f7abb7ba39c25d0a9698ea93b3faca1c8e385102bea003a7504d453e132ad31c1be59bafa4fbe2cb440136e9db8b8ffc20ae50edb237
6
+ metadata.gz: 9f28eecefafbb396aecbb2890654401990581bbfc6037fea41fb76a8716238332d2e70e871f16b7f70dc131f971cfadd4fa4cfa8c548a03c667259090e6d01ac
7
+ data.tar.gz: de90394c5e6e6cad96c24a75b11d1d7627efc29e762c205cba5b845382c1a5b7e45140896e4aaf163ee2d91d01df136442008e8a5bf538567a84787ce01a8f1f
@@ -6,6 +6,7 @@ rvm:
6
6
  - 2.2.3
7
7
  - 2.3.3
8
8
  - 2.3.4
9
+ - 2.3.5
9
10
  before_install: gem install bundler -v 1.11.2
10
11
  group: bluezone
11
12
  script:
@@ -1,3 +1,6 @@
1
+ ## v1.0.0
2
+ ### Changes
3
+ * Blueauth is a class now instead of a module
1
4
  ## v0.0.16
2
5
  ### Changes
3
6
  * Direct IP addresses has been removed, only bluepages.ibm.com remained
data/README.md CHANGED
@@ -24,9 +24,10 @@ Or install it yourself as:
24
24
 
25
25
  The userid can be Intranet ID or Notes ID or Common name
26
26
 
27
- Blueauth::search 'istvan.kovacs@hu.ibm.com'
28
- Blueauth::search 'Istvan Kovacs/Hungary/IBM'
29
- Blueauth::search 'Istvan Kovacs'
27
+ blueauth = Blueauth.new
28
+ blueauth.search 'istvan.kovacs@hu.ibm.com'
29
+ blueauth.search 'Istvan Kovacs/Hungary/IBM'
30
+ blueauth.search 'Istvan Kovacs'
30
31
 
31
32
  If the user is found, then the returned object will be a hash: {:name, :country, :intranetid, :dn}. If the user is not found, then nil
32
33
 
@@ -35,8 +36,9 @@ If the user is found, then the returned object will be a hash: {:name, :country,
35
36
 
36
37
  First, the user must exist in Enterprise Directory, and the Bluegroup can be queried based on the DN of the user
37
38
 
38
- user = Blueauth::search 'istvan.kovacs@hu.ibm.com'
39
- Blueauth::bluegroups user[:dn]
39
+ blueauth = Blueauth.new
40
+ user = blueauth.search 'istvan.kovacs@hu.ibm.com'
41
+ blueauth.bluegroups user[:dn]
40
42
 
41
43
  Returned object will be an Array of strings containing the names of Bluegroups where the user is assigned to.
42
44
 
@@ -44,9 +46,10 @@ Returned object will be an Array of strings containing the names of Bluegroups w
44
46
 
45
47
  The userid can be Intranet ID or Notes ID or Common name
46
48
 
47
- Blueauth::authenticate 'istvan.kovacs@hu.ibm.com', 'password'
48
- Blueauth::authenticate 'Istvan Kovacs/Hungary/IBM', 'password'
49
- Blueauth::authenticate 'Istvan Kovacs', 'password'
49
+ blueauth = Blueauth.new
50
+ blueauth.authenticate 'istvan.kovacs@hu.ibm.com', 'password'
51
+ blueauth.authenticate 'Istvan Kovacs/Hungary/IBM', 'password'
52
+ blueauth.authenticate 'Istvan Kovacs', 'password'
50
53
 
51
54
  If the user is found, then the returned object will be a hash: {:name, :country, :intranetid, :dn, :groups}. Groups is an array containing all Bluegroups. If the user is not found, then nil
52
55
 
@@ -3,44 +3,43 @@ require 'blueauth/error'
3
3
  require 'blueauth/certificates'
4
4
  require 'net-ldap'
5
5
 
6
- module Blueauth
6
+ class Blueauth
7
7
 
8
8
  BPBASE = 'ou=bluepages,o=ibm.com'
9
9
  BGBASE = 'ou=memberlist,ou=ibmgroups,o=ibm.com'
10
-
11
10
  BPHOSTS = [['bluepages.ibm.com',636]]
12
11
 
13
12
  old_verbose, $VERBOSE = $VERBOSE, nil
14
13
  Net::LDAP::LDAPControls::PAGED_RESULTS = FALSE
15
14
  $VERBOSE = old_verbose
16
15
 
17
- @cert_store = OpenSSL::X509::Store.new
18
- @cert_store.add_cert OpenSSL::X509::Certificate.new(NEW_CERT)
19
- @cert_store.add_cert OpenSSL::X509::Certificate.new(OLD_CERT)
16
+ def initialize
17
+
18
+ cert_store = OpenSSL::X509::Store.new
19
+ cert_store.add_cert OpenSSL::X509::Certificate.new(NEW_CERT)
20
+ cert_store.add_cert OpenSSL::X509::Certificate.new(OLD_CERT)
20
21
 
21
- def self.open_ldap
22
- Net::LDAP.new hosts: BPHOSTS, encryption: {
22
+ @ldap = Net::LDAP.new hosts: BPHOSTS, encryption: {
23
23
  method: :simple_tls,
24
- connect_timeout: 15,
24
+ connect_timeout: 20,
25
25
  tls_options: {
26
26
  ssl_version: :TLSv1_2,
27
27
  verify_mode: OpenSSL::SSL::VERIFY_PEER,
28
- cert_store: @cert_store
28
+ cert_store: cert_store
29
29
  }
30
30
  }
31
31
  end
32
32
 
33
33
  # using this method a user can be authenticated
34
34
  # Intraned ID, password are mandatory
35
- def self.authenticate(id, password)
35
+ def authenticate(id, password)
36
36
  user = search id.strip
37
37
  unless user.nil?
38
- ldap = open_ldap
39
- ldap.auth user[:dn], password.strip
38
+ @ldap.auth user[:dn], password.strip
40
39
  begin
41
- auth = ldap.bind
40
+ auth = @ldap.bind
42
41
  rescue => e
43
- raise Blueauth::BlueError, "BluePages Bind issue -> #{e.message}"
42
+ raise BlueError, "BluePages Bind issue -> #{e.message}"
44
43
  end
45
44
  if auth
46
45
  groups = bluegroups user[:dn]
@@ -58,7 +57,7 @@ module Blueauth
58
57
  # - Common name (none of the previous two)
59
58
  # return object contains
60
59
  # :name, :country, :intranetid, :dn
61
- def self.search(id)
60
+ def search(id)
62
61
  if id.include? '@'
63
62
  searchfield = 'mail'
64
63
  elsif id.include? '/'
@@ -83,10 +82,9 @@ module Blueauth
83
82
  end
84
83
  filter = Net::LDAP::Filter.eq(searchfield, id) & Net::LDAP::Filter.eq('objectclass', "ibmPerson")
85
84
  begin
86
- ldap = open_ldap
87
- user_array = ldap.search(base: BPBASE, filter: filter, size: 1)
85
+ user_array = @ldap.search(base: BPBASE, filter: filter, size: 1)
88
86
  rescue => e
89
- raise Blueauth::BlueError, "BluePages Search issue -> #{e.message}"
87
+ raise BlueError, "BluePages Search issue -> #{e.message}"
90
88
  end
91
89
 
92
90
  if user_array.count == 0
@@ -98,15 +96,14 @@ module Blueauth
98
96
  return result
99
97
  end
100
98
 
101
- def self.bluegroups(dn)
99
+ def bluegroups(dn)
102
100
  result = []
103
101
  filter = Net::LDAP::Filter.eq('uniquemember', dn)
104
102
  begin
105
- ldap = open_ldap
106
- bgres = ldap.search(base: BGBASE, filter: filter, attributes: ['cn'])
103
+ bgres = @ldap.search(base: BGBASE, filter: filter, attributes: ['cn'])
107
104
  bgres.each {|g| result << g.cn.first}
108
105
  rescue => e
109
- raise Blueauth::BlueError, "BlueGroup Search issue -> #{e.message}"
106
+ raise BlueError, "BlueGroup Search issue -> #{e.message}"
110
107
  end
111
108
  return result
112
109
  end
@@ -1,4 +1,4 @@
1
- module Blueauth
1
+ class Blueauth
2
2
 
3
3
  # Having only the root signer certificate (DigiCert Global Root G2) in the TLS client truststore is sufficient.
4
4
  # https://w3-connections.ibm.com/wikis/home?lang=en-us#!/wiki/W1f849f7604cc_43a5_a6d9_2ad1fcbc532e/page/Digital%20Certificate%20FAQs
@@ -1,4 +1,4 @@
1
- module Blueauth
1
+ class Blueauth
2
2
  class Error < StandardError
3
3
 
4
4
  def initialize(options = {})
@@ -1,3 +1,3 @@
1
- module Blueauth
2
- VERSION = "0.0.16"
1
+ class Blueauth
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zoltan-izso
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-05 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ldap