keratin-authn 0.3.2 → 0.4.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: 806ffe0f80a2c6e59bd9873478554375bc5f45a4
4
- data.tar.gz: 0b02c5bdd99206aaf381c9919a3ea885ab91804d
3
+ metadata.gz: 41e0f6b3be694546e1b0d6d6c0fc7edc59c31b92
4
+ data.tar.gz: ea05eb73430755ffe1c1206d3a05f4450b760a9c
5
5
  SHA512:
6
- metadata.gz: 8c71e68e2419fd280c82525cd1966520da11c2d51024bcb15d548224e6d46ccd439b87b9edb80d420870c594e7b4d231461666001304516dc792ffdaf1f3ce5b
7
- data.tar.gz: 11b7124b866aae6727a473a717ba465f94c5d8dba90a10463d18028cfa4a4e1172b7614fb6624c4aadaa93514cb12fe86aa6f2bf40d1a05230aa19f19d232bc9
6
+ metadata.gz: 1ce29627b9490406232318c6c7aa1c8ba5487cb25fe3a156a96829668f3d4daf38050b28a7c7d9e56c5235dd2e3d0f0fa7c0b888b88d0ead76e2bd9fb402c221
7
+ data.tar.gz: d1dc214b9a05d61814238ac04763da77d1ac88679da02866d3ca7851c30098ae6eb5fbd92a9f4b48a14076dee86d2f887c648dde9439655793b0c3e9c78dad8f
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /coveralls/
data/README.md CHANGED
@@ -4,7 +4,7 @@ Keratin AuthN is an authentication service that keeps you in control of the expe
4
4
 
5
5
  This gem provides utilities to help integrate with a Ruby application. You may also be interested in keratin/authn-js for frontend integration.
6
6
 
7
- [![Gem Version](https://badge.fury.io/rb/keratin-authn.svg)](http://badge.fury.io/rb/keratin-authn) [![Build Status](https://travis-ci.org/keratin/authn-rb.svg?branch=master)](https://travis-ci.org/keratin/authn-rb)
7
+ [![Gem Version](https://badge.fury.io/rb/keratin-authn.svg)](http://badge.fury.io/rb/keratin-authn) [![Build Status](https://travis-ci.org/keratin/authn-rb.svg?branch=master)](https://travis-ci.org/keratin/authn-rb) [![Coverage Status](https://coveralls.io/repos/github/keratin/authn/badge.svg?branch=master)](https://coveralls.io/github/keratin/authn?branch=master)
8
8
 
9
9
  ## Installation
10
10
 
@@ -50,6 +50,15 @@ logout functionality there as it can also take care of deleting the cookie.
50
50
  * `Keratin.authn.unlock(account_id)`: will unlock an account, restoring normal functionality.
51
51
  * `Keratin.authn.archive(account_id)`: will wipe all personal information, including username and
52
52
  password. Intended for user deletion routine.
53
+ * `Keratin.authn.expire_password(account_id)`: will force the account to reset their password on the
54
+ next login, and revoke all current sessions. Intended for use when password is deemed insecure or
55
+ otherwise expired.
56
+
57
+ ### Other
58
+
59
+ * `Keratin.authn.import(username: user.email, password: user.password, locked: false)`: will create
60
+ an account in Keratin. Intended for importing data from a legacy system. Returns an `account_id`,
61
+ or raises on validation errors.
53
62
 
54
63
  ### Example: Sessions
55
64
 
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency 'timecop'
39
39
  spec.add_development_dependency 'byebug'
40
40
  spec.add_development_dependency 'webmock'
41
+ spec.add_development_dependency 'coveralls'
41
42
  end
@@ -15,6 +15,19 @@ module Keratin::AuthN
15
15
  delete(path: "/accounts/#{account_id}").result
16
16
  end
17
17
 
18
+ # returns account_id or raises exception
19
+ def import(username:, password:, locked: false)
20
+ post(path: '/accounts/import', body: {
21
+ username: username,
22
+ password: password,
23
+ locked: locked
24
+ }).result['id']
25
+ end
26
+
27
+ def expire_password(account_id)
28
+ patch(path: "/accounts/#{account_id}/expire_password")
29
+ end
30
+
18
31
  def signing_key(kid)
19
32
  keys.find{|k| k['use'] == 'sig' && (kid.blank? || kid == k['kid']) }
20
33
  end
@@ -1,5 +1,5 @@
1
1
  module Keratin # rubocop:disable Style/ClassAndModuleChildren
2
2
  module AuthN
3
- VERSION = '0.3.2'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -39,6 +39,10 @@ module Keratin
39
39
  submit(Net::HTTP::Get, **opts)
40
40
  end
41
41
 
42
+ private def post(**opts)
43
+ submit(Net::HTTP::Post, **opts)
44
+ end
45
+
42
46
  private def patch(**opts)
43
47
  submit(Net::HTTP::Patch, **opts)
44
48
  end
@@ -47,11 +51,12 @@ module Keratin
47
51
  submit(Net::HTTP::Delete, **opts)
48
52
  end
49
53
 
50
- private def submit(request_klass, path:)
54
+ private def submit(request_klass, path:, body: nil)
51
55
  uri = URI.parse("#{base}#{path}")
52
56
 
53
57
  request = request_klass.new(uri)
54
58
  request.basic_auth(*@auth) if @auth
59
+ request.set_form_data(body) if body
55
60
 
56
61
  Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
57
62
  http.open_timeout = 0.5
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keratin-authn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lance Ivy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-jwt
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description:
126
140
  email:
127
141
  - lance@cainlevy.net