mongo_kerberos 2.0.0 → 2.1.0

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
- SHA1:
3
- metadata.gz: ee9a349ff716b92f980bcac496566f266bd94247
4
- data.tar.gz: 400120da9cc60b7eba94cfe16af095d5b159537f
2
+ SHA256:
3
+ metadata.gz: 4f0c261a895c98efee67485fede02fe284e0ed01b75ba0dd1f1fa7b5ba9c07c7
4
+ data.tar.gz: f66c7b985d7a29325f8e04f8e29394e919f9b7fa1bd7734bd39aba23eb2dbed8
5
5
  SHA512:
6
- metadata.gz: 9ce6868631cc3f3d67e43f37a33b2e0be688d6f505643ea42bbc09a5982bd87b26fa34bea2567307ea17067f10e4355ccc6d57408c7d54bdb8309d81f0f510f8
7
- data.tar.gz: f81f226ba51bd02577d651b310220e546cba4cd0ea2b9ffd68af26f49dba09296f1e31e7e7b5b245932b259ac52631a6ed858d1aaa28f18f4d12ce6ef628de25
6
+ metadata.gz: f76cb875dab48b38fa290585ef9e5ad15fd22b199ac913bc175557be26e6ba89ec916f093c0effd4edb21bcd6389d63ff73e4c4ea1edb2d51c7325d9c0d7b0b9
7
+ data.tar.gz: 0b8d5ea7c0b2fbb4bb7fcff78b2809e178bd3bbe70c948995e65db4fb9e77acd5122c3a737f2b15ba448fb8dbc24eda60ecd34a707be7e3f66955e19ed7395b2
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,15 +1,21 @@
1
- Mongo Kerberos [![Build Status](https://secure.travis-ci.org/mongodb/mongo-ruby-kerberos.png?branch=master&.png)](http://travis-ci.org/mongodb/mongo-ruby-kerberos) [![Code Climate](https://codeclimate.com/github/mongodb/mongo-ruby-kerberos.png)](https://codeclimate.com/github/mongodb/mongo-ruby-kerberos) [![Coverage Status](https://coveralls.io/repos/mongodb/mongo-ruby-kerberos/badge.png?branch=master)](https://coveralls.io/r/mongodb/mongo-ruby-kerberos?branch=master)
2
- ====
1
+ # Mongo Kerberos [![Build Status](https://secure.travis-ci.org/mongodb/mongo-ruby-kerberos.png?branch=master&.png)](http://travis-ci.org/mongodb/mongo-ruby-kerberos) [![Code Climate](https://codeclimate.com/github/mongodb/mongo-ruby-kerberos.png)](https://codeclimate.com/github/mongodb/mongo-ruby-kerberos) [![Coverage Status](https://coveralls.io/repos/mongodb/mongo-ruby-kerberos/badge.png?branch=master)](https://coveralls.io/r/mongodb/mongo-ruby-kerberos?branch=master)
3
2
 
4
3
  Provides Kerberos authentication support to the Mongo Ruby Driver.
5
4
 
6
- Compatibility
7
- -------------
8
5
 
9
- mongo_kerberos is tested against MRI (1.9.2+) and JRuby (1.7.0+)
6
+ ## Compatibility
10
7
 
11
- Installation
12
- ------------
8
+ mongo_kerberos is tested against MRI (1.9.3+) and JRuby (9.1+).
9
+
10
+ ### JRuby
11
+
12
+ In order to work with Kerberos TGTs that are in the system cache (e.g. obtained with `kinit`), the
13
+ JRuby extension sets the JVM system property "sun.security.jgss.native" to "true". Note that any
14
+ other use of the JGSS library will also be affected by this setting, meaning that any TGTs in the
15
+ system cache will be available for obtaining Kerberos credentials as well.
16
+
17
+
18
+ ## Installation
13
19
 
14
20
  libsasl is a requirement to be able to install the mongo_kerberos gem. Please see the
15
21
  [Cyrus documentation](http://cyrusimap.web.cmu.edu/docs/cyrus-sasl/2.1.25/) for more
@@ -18,7 +24,7 @@ information.
18
24
  With bundler, add the `mongo_kerberos` gem to your `Gemfile`.
19
25
 
20
26
  ```ruby
21
- gem "mongo_kerberos", "~> 2.0"
27
+ gem "mongo_kerberos", "~> 2.1"
22
28
  ```
23
29
 
24
30
  Require the `mongo_kerberos` gem in your application.
@@ -27,17 +33,13 @@ Require the `mongo_kerberos` gem in your application.
27
33
  require "mongo_kerberos"
28
34
  ```
29
35
 
30
- Usage
31
- -----
32
-
33
36
 
34
- API Documentation
35
- -----------------
37
+ ## API Documentation
36
38
 
37
39
  The [API Documentation](http://rdoc.info/github/mongodb/mongo-ruby-kerberos/master/frames) is
38
40
  located at rdoc.info.
39
41
 
40
- Versioning
41
- ----------
42
+ ## Versioning
42
43
 
43
- As of 2.0.0, this project adheres to the [Semantic Versioning Specification](http://semver.org/).
44
+ As of 2.1.0, this project adheres to the
45
+ [Semantic Versioning Specification](http://semver.org/).
data/Rakefile CHANGED
@@ -35,9 +35,9 @@ if jruby?
35
35
  else
36
36
  require "rake/extensiontask"
37
37
  Rake::ExtensionTask.new do |ext|
38
- ext.name = "native"
39
- ext.ext_dir = "ext/mongo/kerberos"
40
- ext.lib_dir = "lib/mongo/auth/kerberos"
38
+ ext.name = "mongo_kerberos_native"
39
+ ext.ext_dir = "ext/mongo_kerberos"
40
+ ext.lib_dir = "lib"
41
41
  end
42
42
  end
43
43
 
@@ -62,9 +62,11 @@ end
62
62
  task :clean_all => :clean do
63
63
  begin
64
64
  Dir.chdir(Pathname(__FILE__).dirname + "lib") do
65
- `rm native.#{extension}`
66
- `rm native.o`
67
- `rm native.jar`
65
+ ["o", extension, "jar"].each do |e|
66
+ Dir.glob(File.join("**", "*.#{e}")).each do |f|
67
+ `rm #{f}`
68
+ end
69
+ end
68
70
  end
69
71
  rescue Exception => e
70
72
  puts e.message
@@ -94,3 +96,15 @@ task :release => :build do
94
96
  end
95
97
 
96
98
  task :default => [ :clean_all, :spec ]
99
+
100
+ desc "Generate all documentation"
101
+ task :docs => 'docs:yard'
102
+
103
+ namespace :docs do
104
+ desc "Generate yard documention"
105
+ task :yard do
106
+ out = File.join('yard-docs', Mongo::Auth::Kerberos::VERSION)
107
+ FileUtils.rm_rf(out)
108
+ system "yardoc -o #{out} --title mongo-ruby-kerberos-#{Mongo::Auth::Kerberos::VERSION}"
109
+ end
110
+ end
@@ -1,7 +1,7 @@
1
1
  require 'mkmf'
2
2
  find_header('sasl/sasl.h')
3
3
  if have_library('sasl2', 'sasl_version')
4
- create_makefile('native')
4
+ create_makefile('mongo_kerberos_native')
5
5
  else
6
6
  abort "libsasl (cyrus sasl) is required in the system to install the mongo_kerberos gem."
7
7
  end
@@ -18,8 +18,14 @@
18
18
 
19
19
  static void mongo_sasl_conn_free(void* data) {
20
20
  sasl_conn_t *conn = (sasl_conn_t*) data;
21
- // Ideally we would use sasl_client_done() but that's only available as of cyrus sasl 2.1.25
22
- if(conn) sasl_done();
21
+ if (conn) {
22
+ sasl_dispose(&conn);
23
+ /* We do not set connection to NULL in the Ruby object. */
24
+ /* This is probably fine because this method is supposed to be called */
25
+ /* when the Ruby object is being garbage collected. */
26
+ /* Plus, we don't have the Ruby object reference here to do anything */
27
+ /* with it. */
28
+ }
23
29
  }
24
30
 
25
31
  static sasl_conn_t* mongo_sasl_context(VALUE self) {
@@ -104,7 +110,14 @@ static VALUE initialize_challenge(VALUE self) {
104
110
  }
105
111
 
106
112
  context = Data_Wrap_Struct(rb_cObject, NULL, mongo_sasl_conn_free, conn);
113
+ /* I'm guessing ruby raises on out of memory condition rather than */
114
+ /* returns NULL, hence no error checking is needed here? */
115
+
116
+ /* from now on context owns conn */
117
+ /* since mongo_sasl_conn_free cleans up conn, we should NOT call */
118
+ /* sasl_dispose any more in this function. */
107
119
  rb_iv_set(self, "@context", context);
120
+ RB_GC_GUARD(context);
108
121
 
109
122
  result = sasl_client_start(conn, mechanism_list, NULL, &raw_payload, &raw_payload_len, &mechanism_selected);
110
123
  if (is_sasl_failure(result)) {
@@ -115,7 +128,9 @@ static VALUE initialize_challenge(VALUE self) {
115
128
  return Qfalse;
116
129
  }
117
130
 
118
- result = sasl_encode64(raw_payload, raw_payload_len, encoded_payload, sizeof(encoded_payload), &encoded_payload_len);
131
+ /* cyrus-sasl considers `outmax` (fourth argument) to include the null */
132
+ /* terminator, but this is not documented. Be defensive and exclude it. */
133
+ result = sasl_encode64(raw_payload, raw_payload_len, encoded_payload, sizeof(encoded_payload)-1, &encoded_payload_len);
119
134
  if (is_sasl_failure(result)) {
120
135
  return Qfalse;
121
136
  }
@@ -135,17 +150,17 @@ static VALUE evaluate_challenge(VALUE self, VALUE rb_payload) {
135
150
  step_payload = RSTRING_PTR(rb_payload);
136
151
  step_payload_len = (int)RSTRING_LEN(rb_payload);
137
152
 
138
- result = sasl_decode64(step_payload, step_payload_len, base_payload, sizeof(base_payload), &base_payload_len);
153
+ result = sasl_decode64(step_payload, step_payload_len, base_payload, sizeof(base_payload)-1, &base_payload_len);
139
154
  if (is_sasl_failure(result)) {
140
155
  return Qfalse;
141
156
  }
142
157
 
143
158
  result = sasl_client_step(conn, base_payload, base_payload_len, NULL, &out, &outlen);
144
159
  if (is_sasl_failure(result)) {
145
- return Qfalse;
160
+ return Qfalse;
146
161
  }
147
162
 
148
- result = sasl_encode64(out, outlen, payload, sizeof(payload), &payload_len);
163
+ result = sasl_encode64(out, outlen, payload, sizeof(payload)-1, &payload_len);
149
164
  if (is_sasl_failure(result)) {
150
165
  return Qfalse;
151
166
  }
@@ -155,7 +170,7 @@ static VALUE evaluate_challenge(VALUE self, VALUE rb_payload) {
155
170
 
156
171
  VALUE c_GSSAPI_authenticator;
157
172
 
158
- void Init_native() {
173
+ void Init_mongo_kerberos_native() {
159
174
  VALUE mongo, auth;
160
175
  mongo = rb_const_get(rb_cObject, rb_intern("Mongo"));
161
176
  auth = rb_const_get(mongo, rb_intern("Auth"));
@@ -22,13 +22,24 @@ module Mongo
22
22
  #
23
23
  # @since 2.0.0
24
24
  class Kerberos
25
- include Executable
26
25
 
27
- # The authentication mechinism string.
26
+ # The authentication mechanism string.
28
27
  #
29
28
  # @since 2.0.0
30
29
  MECHANISM = 'GSSAPI'.freeze
31
30
 
31
+ # Instantiate a new authenticator.
32
+ #
33
+ # example Create the authenticator.
34
+ # Mongo::Auth::Kerberos.new(user)
35
+ #
36
+ # @param [ Mongo::Auth::User ] user The user to authenticate.
37
+ #
38
+ # @since 2.0.1
39
+ def initialize(user)
40
+ @user = user
41
+ end
42
+
32
43
  # Log the user in on the given connection.
33
44
  #
34
45
  # @example Log the user in.
@@ -41,10 +52,12 @@ module Mongo
41
52
  #
42
53
  # @since 2.0.0
43
54
  def login(connection)
44
- conversation = Conversation.new(user, connection.address.host)
55
+ conversation = Conversation.new(@user, connection.address.host)
45
56
  reply = connection.dispatch([ conversation.start ])
57
+ connection.update_cluster_time(Operation::Result.new(reply))
46
58
  until reply.documents[0][Conversation::DONE]
47
59
  reply = connection.dispatch([ conversation.finalize(reply) ])
60
+ connection.update_cluster_time(Operation::Result.new(reply))
48
61
  end
49
62
  reply
50
63
  end
@@ -113,7 +113,7 @@ module Mongo
113
113
 
114
114
  # Create the new conversation.
115
115
  #
116
- # @example Create the new coversation.
116
+ # @example Create the new conversation.
117
117
  # Conversation.new(user, 'test.example.com')
118
118
  #
119
119
  # @param [ Auth::User ] user The user to converse about.
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'java'
16
- require 'mongo/auth/kerberos/jsasl.jar'
17
16
  require 'mongo/auth/kerberos/native.jar'
18
17
 
19
18
  module Mongo
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'mongo/auth/kerberos/native'
15
+ require 'mongo_kerberos_native'
16
16
 
17
17
  module Mongo
18
18
  module Auth
@@ -17,7 +17,7 @@ module Mongo
17
17
  class Kerberos
18
18
 
19
19
  # The gem version number.
20
- VERSION = '2.0.0'.freeze
20
+ VERSION = '2.1.0'.freeze
21
21
  end
22
22
  end
23
23
  end
@@ -20,6 +20,17 @@ describe Mongo::Auth::Kerberos::Conversation do
20
20
  and_return(authenticator)
21
21
  end
22
22
 
23
+ context 'when the user has a realm', if: RUBY_PLATFORM == 'java' do
24
+
25
+ let(:user) do
26
+ Mongo::Auth::User.new(user: 'user1@MYREALM.ME')
27
+ end
28
+
29
+ it 'includes the realm in the username as it was provided' do
30
+ expect(conversation.user.name).to eq(user.name)
31
+ end
32
+ end
33
+
23
34
  describe '#start' do
24
35
 
25
36
  let(:query) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_kerberos
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emily Stolfo
@@ -11,27 +11,26 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
15
- ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
16
- Y29tMB4XDTE0MTEyMDE1NTYxOVoXDTE1MTEyMDE1NTYxOVowQjEUMBIGA1UEAwwL
17
- ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
18
- ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
19
- bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
20
- IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
21
- JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
22
- 4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
23
- 5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
24
- u8KAcPHm5KkCAwEAAaN9MHswCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
25
- BBYEFFt3WbF+9JpUjAoj62cQBgNb8HzXMCAGA1UdEQQZMBeBFWRyaXZlci1ydWJ5
26
- QDEwZ2VuLmNvbTAgBgNVHRIEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5jb20wDQYJ
27
- KoZIhvcNAQEFBQADggEB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IwKI+tnEAYDW/B81zAgBgNVHREEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5j
25
+ b20wIAYDVR0SBBkwF4EVZHJpdmVyLXJ1YnlAMTBnZW4uY29tMA0GCSqGSIb3DQEB
26
+ CwUAA4IBAQAaVV3xYYK7qtbnTzctqafLFN4d6amxzWGs4KYpnCSr1BRJQYIiq8Zp
27
+ hjTZoOQlEiUP/4TlNg81sO4TY8RPbE3SAeIEfPWTiQYT7bD51KwOdOtegXSbhn5a
28
+ hEjUXYxYpVJdAqh4BGT78TY/3M1oPpOLnWRUI5TQ8S1BT5C+dqJG8fZW04C50LdL
29
+ P3JIZhI5pIae1pnGh/lS4oxAUxMVuILPJwHbtK7RkiIUOv3PA0JkPDnKLlKVSMks
30
+ oJ3hhwXc2QCuggX+vYTfFkm49uIb1jzivtRTIDwRWCfp3KKtV85BCM0UDTJqZBDe
31
+ JvwE2HAT8fOpY1c60+KRpfRKddtgMo7R
33
32
  -----END CERTIFICATE-----
34
- date: 2015-03-25 00:00:00.000000000 Z
33
+ date: 2019-01-11 00:00:00.000000000 Z
35
34
  dependencies:
36
35
  - !ruby/object:Gem::Dependency
37
36
  name: mongo
@@ -39,21 +38,21 @@ dependencies:
39
38
  requirements:
40
39
  - - "~>"
41
40
  - !ruby/object:Gem::Version
42
- version: 2.0.0
41
+ version: '2.0'
43
42
  type: :runtime
44
43
  prerelease: false
45
44
  version_requirements: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - "~>"
48
47
  - !ruby/object:Gem::Version
49
- version: 2.0.0
48
+ version: '2.0'
50
49
  description: Adds Kerberos authentication via libsasl to the MongoDB Ruby Driver on
51
50
  MRI and JRuby
52
51
  email:
53
52
  - mongodb-dev@googlegroups.com
54
53
  executables: []
55
54
  extensions:
56
- - ext/mongo/kerberos/extconf.rb
55
+ - ext/mongo_kerberos/extconf.rb
57
56
  extra_rdoc_files: []
58
57
  files:
59
58
  - CONTRIBUTING.md
@@ -61,15 +60,12 @@ files:
61
60
  - NOTICE
62
61
  - README.md
63
62
  - Rakefile
64
- - ext/mongo/kerberos/extconf.rb
65
- - ext/mongo/kerberos/native.c
63
+ - ext/mongo_kerberos/extconf.rb
64
+ - ext/mongo_kerberos/mongo_kerberos_native.c
66
65
  - lib/mongo/auth/kerberos.rb
67
66
  - lib/mongo/auth/kerberos/conversation.rb
68
67
  - lib/mongo/auth/kerberos/jruby/authenticator.rb
69
- - lib/mongo/auth/kerberos/jsasl.jar
70
68
  - lib/mongo/auth/kerberos/mri/authenticator.rb
71
- - lib/mongo/auth/kerberos/native.bundle
72
- - lib/mongo/auth/kerberos/native.jar
73
69
  - lib/mongo/auth/kerberos/version.rb
74
70
  - lib/mongo_kerberos.rb
75
71
  - spec/mongo/auth/kerberos/conversation_spec.rb
@@ -95,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
91
  version: 1.3.6
96
92
  requirements: []
97
93
  rubyforge_project: mongo_kerberos
98
- rubygems_version: 2.2.2
94
+ rubygems_version: 2.7.6
99
95
  signing_key:
100
96
  specification_version: 4
101
97
  summary: Kerberos authentication support for the MongoDB Ruby driver
metadata.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- �<��xM~��t�,��͑�)a��'F���%���e LՕ=���q^R�L"}�,�Yk8�y���(�h���H��^�� {�j�k�r'��3h`�'�������7b�� 4D�vb"�}��Oo�N��.[)�ߧ�
2
- ��"�Q�n,6tMnN�>�A�"8yU�b<��\�� ��x�I��~��C�����]n�ht
3
- �@o����6
1
+ &�3\���8���`:�'�� R f[�+�-Zs7��r�.&�:b��tf
2
+ J$Me;A���)�����E��u��E�++l��)E ��7���A����h����$������ﻞTM��5Cˑ�=[i/��`�;0{*4�
3
+ ʖS �N�J�����Q��qW�����l]�hEɺ�$W�zdiƞ��u�{��:����A�y���/lst(U�.qw�}�N��)�����!�19�8p�`Y����@0;B����{��%