cyclid-client 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 8e0ed4474b3e654888e5af98ce8651e7185c86c4
4
- data.tar.gz: ec58a0848ac45a46b4958491b1da1b6dc90e5b89
3
+ metadata.gz: eb286d1fdb3a5a900ad24f35c41fff997b9403eb
4
+ data.tar.gz: d62a803b0a9597605906bedc394a1277d9e9bf45
5
5
  SHA512:
6
- metadata.gz: 8b84d6e3bf1b4debc7848d9e75a5b311a361cd94ad5856c175619cdae694a7e456e2854d24a1abd2925bf9fa99121bd2fb9d0160e2386d7ef7efbbf760615c71
7
- data.tar.gz: 825e9d50626ce58d262f8e3b01a17c0c59684467dc209b4538c000d676466f97ba8956b87501c33451aef267fe75f8e4773c282eab0ee810bf87357944d85c6a
6
+ metadata.gz: 8f5a28f869c93715ff81ff3e25da32bf088f9a2ca417a78708a9845aa6ab7312a8decafd3dd8e688888bc1a2ed70e99f0b3e66b909172843dc626614489f3916
7
+ data.tar.gz: 614077b06d871c421644adc3ccd0ad10af187521a6afb6a35bfcfe84d697fe46183750d1f4490b7f9568266a4e2176b5c0f79c86b57fa9aa648c178a10e9d1cb
@@ -49,7 +49,8 @@ module Cyclid
49
49
  # @param username [String] User name of the new user.
50
50
  # @param name [String] Users real name.
51
51
  # @param email [String] Users email address.
52
- # @param password [String] Unencrypted initial password
52
+ # @param password [String] Unencrypted initial password OR a BCrypt2
53
+ # encrypted password string.
53
54
  # @param secret [String] Initial HMAC signing secret
54
55
  # @return [Hash] Decoded server response object.
55
56
  # @see #user_modify
@@ -64,8 +65,14 @@ module Cyclid
64
65
  # Add the HMAC secret if one was supplied
65
66
  user['secret'] = secret unless secret.nil?
66
67
 
67
- # Encrypt & add the password if one was supplied
68
- user['password'] = BCrypt::Password.create(password).to_s unless password.nil?
68
+ # Add the password if one was supplied
69
+ user['password'] = if password =~ /\A\$2a\$.+\z/
70
+ # Password is already encrypted
71
+ password
72
+ else
73
+ # Encrypt the plaintext password
74
+ BCrypt::Password.create(password).to_s
75
+ end unless password.nil?
69
76
 
70
77
  @logger.debug user
71
78
 
@@ -84,6 +91,8 @@ module Cyclid
84
91
  # @option args [String] email Users email address.
85
92
  # @option args [String] secret Initial HMAC signing secret
86
93
  # @option args [String] password Unencrypted initial password
94
+ # @option args [String] password Unencrypted initial password OR a
95
+ # BCrypt2 encrypted password string.
87
96
  # @return [Hash] Decoded server response object.
88
97
  # @see #user_add
89
98
  # @see #user_delete
@@ -104,9 +113,14 @@ module Cyclid
104
113
  # Add the HMAC secret if one was supplied
105
114
  user['secret'] = args[:secret] if args.key? :secret and args[:secret]
106
115
 
107
- # Encrypt & add the password if one was supplied
108
- user['password'] = BCrypt::Password.create(args[:password]).to_s \
109
- if args.key? :password and args[:password]
116
+ # Add the password if one was supplied
117
+ user['password'] = if args[:password] =~ /\A\$2a\$.+\z/
118
+ # Password is already encrypted
119
+ args[:password]
120
+ else
121
+ # Encrypt the plaintext password
122
+ BCrypt::Password.create(args[:password]).to_s
123
+ end if args.key? :password and args[:password]
110
124
 
111
125
  @logger.debug user
112
126
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Cyclid
3
3
  module Client
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-24 00:00:00.000000000 Z
11
+ date: 2016-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor