net-ldap-gss-spnego 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/lib/net-ldap-gss-spnego.rb +3 -0
- data/lib/net/ldap/auth_adapter/gss_spnego.rb +48 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b35cf924b240586cfe072aaf96e728e8abf3041f1ed85d7288261c16bd912cf1
|
4
|
+
data.tar.gz: 5259002385da9595cbe76d27a30f0e10e3d08c2283cfe41cb4659664489b8615
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 350085eac99c80933b3769be57bae7ef0da264742844123c9e20f294f84cb9222d4e3d17faef59546ec44e869f62175a2214769d92605c7d31ff544456822f5b
|
7
|
+
data.tar.gz: 76b142e36b0b44f0bc7a69568529cba8fe25e03e86519888a73da95c75ec733f5ae2f0584e35f925d2770a0d75141e4cc6ae43de0e0993c76bf97305a1dc1edc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Florian Wininger
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# ruby-net-ldap-gss-spnego
|
2
|
+
|
3
|
+
Adapter for GSS-SPNEGO authentication in net-ldap gem
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'net-ldap-gss-spnego'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ gem install net-ldap-gss-spnego
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'net/ldap/auth_adapter/gss_spnego'
|
29
|
+
|
30
|
+
ldap = Net::LDAP.new(
|
31
|
+
auth: {
|
32
|
+
method: :gss_spnego,
|
33
|
+
username: 'administrator',
|
34
|
+
password: 'Pa$$w0rd'
|
35
|
+
}
|
36
|
+
)
|
37
|
+
```
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/ldap/auth_adapter'
|
4
|
+
require 'net/ldap/auth_adapter/sasl'
|
5
|
+
require 'rubyntlm'
|
6
|
+
|
7
|
+
module Net
|
8
|
+
class LDAP
|
9
|
+
class AuthAdapter
|
10
|
+
# This authentication method is accessed by calling #bind with a :method
|
11
|
+
# parameter of :gss_spnego. It requires :username, :password and :basename
|
12
|
+
# attributes, just like the :simple authentication method. It performs a
|
13
|
+
# GSS-SPNEGO authentication with the server, which is presumed to be a
|
14
|
+
# Microsoft Active Directory.
|
15
|
+
#++
|
16
|
+
class GssSpnego < Net::LDAP::AuthAdapter
|
17
|
+
def bind(auth)
|
18
|
+
user = auth[:username] || auth[:dn]
|
19
|
+
password = auth[:password]
|
20
|
+
domain = auth[:domain]
|
21
|
+
|
22
|
+
unless user && password
|
23
|
+
raise Net::LDAP::BindingInformationInvalidError, 'Invalid binding information'
|
24
|
+
end
|
25
|
+
|
26
|
+
challenge_response = proc do |challenge|
|
27
|
+
challenge.force_encoding(Encoding::BINARY)
|
28
|
+
t2_msg = NTLM::Message.parse(challenge)
|
29
|
+
auth_params = { user: user, password: password }
|
30
|
+
auth_params[:domain] = domain unless domain.blank?
|
31
|
+
t3_msg = t2_msg.response(auth_params, ntlmv2: true)
|
32
|
+
t3_msg.user.force_encoding(Encoding::BINARY)
|
33
|
+
t3_msg.serialize
|
34
|
+
end
|
35
|
+
|
36
|
+
Net::LDAP::AuthAdapter::Sasl.new(@connection).bind(
|
37
|
+
method: :sasl,
|
38
|
+
mechanism: 'GSS-SPNEGO',
|
39
|
+
initial_credential: NTLM::Message::Type1.new.serialize,
|
40
|
+
challenge_response: challenge_response
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Net::LDAP::AuthAdapter.register(:gss_spnego, Net::LDAP::AuthAdapter::GssSpnego)
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: net-ldap-gss-spnego
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florian Wininger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-ldap
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.16'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyntlm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.79.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.79.0
|
55
|
+
description: Add the GSS-SPNEGO authentication mechanism in net-ldap gem
|
56
|
+
email:
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- LICENSE
|
62
|
+
- README.md
|
63
|
+
- lib/net-ldap-gss-spnego.rb
|
64
|
+
- lib/net/ldap/auth_adapter/gss_spnego.rb
|
65
|
+
homepage: https://github.com/fwininger/ruby-net-ldap-gss-spnego
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.4.0
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.0.3
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Adapter for GSS-SPNEGO authentication in net-ldap gem
|
88
|
+
test_files: []
|