authrocket 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +144 -0
- data/Rakefile +1 -0
- data/authrocket.gemspec +25 -0
- data/lib/authrocket.rb +11 -0
- data/lib/authrocket/api/api_config.rb +78 -0
- data/lib/authrocket/api/log_subscriber.rb +10 -0
- data/lib/authrocket/api/railtie.rb +13 -0
- data/lib/authrocket/api/version.rb +3 -0
- data/lib/authrocket/app_hook.rb +25 -0
- data/lib/authrocket/event.rb +24 -0
- data/lib/authrocket/login_policy.rb +14 -0
- data/lib/authrocket/membership.rb +26 -0
- data/lib/authrocket/org.rb +22 -0
- data/lib/authrocket/realm.rb +22 -0
- data/lib/authrocket/user.rb +76 -0
- data/lib/authrocket/user_token.rb +10 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 180feb604cb15ff4e7e37c7165dd82dfe8be07e7
|
4
|
+
data.tar.gz: b1fed38444acc277dbdad9750f4ec065af2d7114
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 17f94dff2a42d7c832278009e12a55664dee8167cd42cff41e39eb6b909d62823f32cb0871494966f3933f607d61c7950fe8b8191ddaa4b7f9c62b349cedf404
|
7
|
+
data.tar.gz: 6cdee5088181c2ca12a4988b9d204455fc85a77b2d3e27ed9de5230179d8a64147dca3d33e691b2f98d3f84e8b78c43190f56109af3885528b8c3da7601ba334
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Notioneer, Inc.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# AuthRocket
|
2
|
+
|
3
|
+
[AuthRocket](http://authrocket.com/) provides Auth as a Service, making it quick and easy to add signups, logins, a full user management UI, and much more to your app.
|
4
|
+
|
5
|
+
This gem works with both Rails and plain Ruby. It will auto-detect Rails and enable a couple Rails-specific features as appropriate.
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
For installation, add `gem 'authrocket'` to your Gemfile. More details are below.
|
11
|
+
|
12
|
+
|
13
|
+
### Configuration
|
14
|
+
|
15
|
+
By default, AuthRocket automatically loads your credentials from environment variables. For such hosting environments, including Heroku, just configure these:
|
16
|
+
|
17
|
+
AUTHROCKET_ACCOUNT = org_SAMPLE
|
18
|
+
AUTHROCKET_API_KEY = key_SAMPLE
|
19
|
+
AUTHROCKET_URL = https://api-e1.authrocket.com/v1
|
20
|
+
AUTHROCKET_REALM = rl_SAMPLE # optional
|
21
|
+
|
22
|
+
`AUTHROCKET_URL` must be updated based on what cluster your account is provisioned on.
|
23
|
+
|
24
|
+
`AUTHROCKET_REALM` is optional. If you're using a single Realm, it's easiest to add it here as an application-wide default. If you're using multiple Realms with your app, we recommend leaving it out here and setting it as you go.
|
25
|
+
|
26
|
+
It's possible to configure AuthRocket using a Rails initializer (or other initializaiton code) too.
|
27
|
+
|
28
|
+
AuthRocket::Api.credentials = {
|
29
|
+
account: 'org_SAMPLE',
|
30
|
+
api_key: 'key_SAMPLE',
|
31
|
+
url: 'https://api-e1.authrocket.com/v1',
|
32
|
+
realm: 'rl_SAMPLE'
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
### Hosted Logins
|
37
|
+
|
38
|
+
AuthRocket has a few options to handle logins. One option is to let AuthRocket handle the login process completely, which is what's shown here. Your app only needs to verify the final login token. This example is specific to Rails, but adapt accordingly for Sinatra or any other framework.
|
39
|
+
|
40
|
+
To get started, login to AuthRocket and add a Login Policy (under Logins/Signups) for your chosen Realm (create your first Realm if you haven't already).
|
41
|
+
|
42
|
+
Be sure to enable Hosted Logins (a separate step) and specify a Login Handler URL. For development purposes, we'll point the Login Handler URL to your local app. Assuming your Rails app is running on port 3000, you'd enter `http://localhost:3000/login`.
|
43
|
+
|
44
|
+
After enabling Hosted Logins, take note of the LoginRocket URL. You'll need this below.
|
45
|
+
|
46
|
+
Let's add a couple methods to your Application Controller, substituting the correct value for `LOGIN_URL`:
|
47
|
+
|
48
|
+
class ApplicationController < ActionController::Base
|
49
|
+
before_filter :require_user
|
50
|
+
# This protects *all* of your app. If that's not what
|
51
|
+
# you want, then just add this to the controllers
|
52
|
+
# that need to be protected.
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
LOGIN_URL = 'https://sample.e1.loginrocket.com/
|
57
|
+
# This should be your app's own LoginRocket URL, as
|
58
|
+
# shown in the Login Policy details.
|
59
|
+
|
60
|
+
def require_user
|
61
|
+
unless session[:ar_user_id]
|
62
|
+
flash.keep
|
63
|
+
redirect_to LOGIN_URL
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def current_user
|
68
|
+
@_current_user ||= session[:ar_user_id] && AuthRocket::User.find(session[:ar_user_id])
|
69
|
+
end
|
70
|
+
|
71
|
+
def current_user_name
|
72
|
+
session[:name]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
Create a Login or Session controller if you don't have one already:
|
77
|
+
|
78
|
+
rails g controller logins
|
79
|
+
|
80
|
+
Then add login and logout methods:
|
81
|
+
|
82
|
+
class LoginsController < ApplicationController
|
83
|
+
skip_before_filter :require_user
|
84
|
+
|
85
|
+
def login
|
86
|
+
flash.keep
|
87
|
+
if params[:token]
|
88
|
+
if login_rec = AuthRocket::Event.validate_token(params[:token])
|
89
|
+
user = login_rec.user
|
90
|
+
session[:ar_user_id] = user.id
|
91
|
+
session[:name] = user.name
|
92
|
+
redirect_to root_path
|
93
|
+
return
|
94
|
+
end
|
95
|
+
end
|
96
|
+
require_user
|
97
|
+
end
|
98
|
+
|
99
|
+
def logout
|
100
|
+
session[:ar_user_id] = nil
|
101
|
+
redirect_to root_path, notice: 'You have been logged out.'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
Finally, update `config/routes.rb`:
|
106
|
+
|
107
|
+
get '/login' => 'logins#login'
|
108
|
+
get '/logout' => 'logins#logout'
|
109
|
+
|
110
|
+
That's it. You're all done!
|
111
|
+
|
112
|
+
|
113
|
+
### Other Methods
|
114
|
+
|
115
|
+
For full details on the AuthRocket API, including examples for Ruby, see our [documentation](http://authrocket.com/docs).
|
116
|
+
|
117
|
+
|
118
|
+
## Installation
|
119
|
+
|
120
|
+
Add this line to your application's Gemfile:
|
121
|
+
|
122
|
+
gem 'authrocket'
|
123
|
+
|
124
|
+
And then execute:
|
125
|
+
|
126
|
+
$ bundle
|
127
|
+
|
128
|
+
Or install it yourself as:
|
129
|
+
|
130
|
+
$ gem install authrocket
|
131
|
+
|
132
|
+
|
133
|
+
## Contributing
|
134
|
+
|
135
|
+
1. Fork it
|
136
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
137
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
138
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
139
|
+
5. Create new Pull Request
|
140
|
+
|
141
|
+
|
142
|
+
## License
|
143
|
+
|
144
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/authrocket.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'authrocket/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "authrocket"
|
8
|
+
gem.version = AuthRocket::VERSION
|
9
|
+
gem.authors = ["thomas morgan"]
|
10
|
+
gem.email = ["tm@notioneer.com"]
|
11
|
+
gem.description = %q{AuthRocket client for Ruby.}
|
12
|
+
gem.summary = %q{AuthRocket client for Ruby}
|
13
|
+
gem.homepage = "https://github.com/authrocket/authrocket-ruby"
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency 'ncore', '~> 1.0'
|
22
|
+
|
23
|
+
gem.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
end
|
data/lib/authrocket.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'ncore'
|
2
|
+
|
3
|
+
%w(version api_config).each do |f|
|
4
|
+
require "authrocket/api/#{f}"
|
5
|
+
end
|
6
|
+
|
7
|
+
%w(app_hook event login_policy membership org realm user user_token).each do |f|
|
8
|
+
require "authrocket/#{f}"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'authrocket/api/railtie' if defined?(Rails)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
include NCore::Builder
|
3
|
+
|
4
|
+
configure do
|
5
|
+
self.default_url = ENV['AUTHROCKET_URL']
|
6
|
+
|
7
|
+
self.default_headers = {
|
8
|
+
accept: 'application/json',
|
9
|
+
content_type: 'application/json',
|
10
|
+
user_agent: "AuthRocket/ruby v#{VERSION} [nc #{NCore::VERSION}]"
|
11
|
+
}
|
12
|
+
|
13
|
+
if ENV['AUTHROCKET_URI']
|
14
|
+
self.credentials = parse_credentials ENV['AUTHROCKET_URI']
|
15
|
+
elsif ENV['AUTHROCKET_API_KEY']
|
16
|
+
self.credentials = {
|
17
|
+
api_key: ENV['AUTHROCKET_API_KEY'],
|
18
|
+
account: ENV['AUTHROCKET_ACCOUNT'],
|
19
|
+
realm: ENV['AUTHROCKET_REALM']
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
self.debug = false
|
24
|
+
|
25
|
+
self.strict_attributes = true
|
26
|
+
|
27
|
+
|
28
|
+
self.instrument_key = 'request.authrocket'
|
29
|
+
|
30
|
+
self.status_page = 'http://status.notioneer.com/'
|
31
|
+
|
32
|
+
self.auth_header_prefix = 'X-Authrocket'
|
33
|
+
|
34
|
+
self.credentials_error_message = %Q{Missing API credentials or URL. Set default credentials using "AuthRocket::Api.credentials = {api_key: YOUR_API_KEY, account: YOUR_ACCOUNT_ID, url: AR_REGION_URL}"}
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
class << self
|
39
|
+
# makes AuthRocket::Realm.model_name.param_key do the right thing
|
40
|
+
def use_relative_model_naming?
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_credentials(creds)
|
48
|
+
case creds
|
49
|
+
when String
|
50
|
+
url = URI.parse creds rescue nil
|
51
|
+
if url
|
52
|
+
o = {}
|
53
|
+
[url.password, url.user].each do |part|
|
54
|
+
case part
|
55
|
+
when /^key_/
|
56
|
+
o[:api_key] = part
|
57
|
+
when /^org_/
|
58
|
+
o[:account] = part
|
59
|
+
when /^rl_/
|
60
|
+
o[:realm] = part
|
61
|
+
end
|
62
|
+
end
|
63
|
+
url.user = url.password = nil
|
64
|
+
o[:url] = url.to_s
|
65
|
+
o
|
66
|
+
else
|
67
|
+
raise Error, 'Unable to parse AuthRocket credentials URI'
|
68
|
+
end
|
69
|
+
|
70
|
+
when NilClass
|
71
|
+
{}
|
72
|
+
else
|
73
|
+
creds
|
74
|
+
end.with_indifferent_access
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
|
4
|
+
initializer "authrocket.log_runtime" do |app|
|
5
|
+
require 'authrocket/api/log_subscriber'
|
6
|
+
ActiveSupport.on_load(:action_controller) do
|
7
|
+
include NCore::ControllerRuntime
|
8
|
+
register_api_runtime AuthRocket::LogSubscriber, 'AuthRocket'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class AppHook < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :realm
|
6
|
+
has_many :events
|
7
|
+
|
8
|
+
attr :event_type, :hook_type, :destination, :email_from, :user_type, :email_subject, :email_template
|
9
|
+
|
10
|
+
def self.event_types
|
11
|
+
%w( *
|
12
|
+
realm.* realm.created realm.updated realm.deleted
|
13
|
+
user.* user.created user.updated user.deleted
|
14
|
+
user.login.* user.login.succeeded user.login.failed
|
15
|
+
user.password_token.* user.password_token.created user.password_token.consumed user.password_token.failed
|
16
|
+
org.* org.created org.updated org.deleted
|
17
|
+
membership.* membership.created membership.updated membership.deleted
|
18
|
+
app_hook.* app_hook.created app_hook.updated app_hook.deleted
|
19
|
+
login_policy.* login_policy.created login_policy.updated login_policy.deleted
|
20
|
+
).sort
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class Event < Resource
|
3
|
+
crud :all, :find
|
4
|
+
|
5
|
+
belongs_to :app_hook
|
6
|
+
belongs_to :login_policy
|
7
|
+
belongs_to :membership
|
8
|
+
belongs_to :org
|
9
|
+
belongs_to :realm
|
10
|
+
belongs_to :user
|
11
|
+
|
12
|
+
attr :event_type, :ip
|
13
|
+
attr_datetime :event_at
|
14
|
+
|
15
|
+
|
16
|
+
def self.validate_token(token, params={}, api_creds=nil)
|
17
|
+
parsed, creds = request(:get, "#{url}/login/#{CGI.escape token}", api_creds, params)
|
18
|
+
new(parsed, creds)
|
19
|
+
rescue RecordNotFound
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class LoginPolicy < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :realm
|
6
|
+
has_many :events
|
7
|
+
|
8
|
+
attr :custom_domains, :enable_logins, :enable_signups, :external_css
|
9
|
+
attr :footer, :header, :login_handler, :name, :name_field, :primary_domain
|
10
|
+
attr :signup_handler, :subdomain
|
11
|
+
attr :base_domain, :domains # readonly
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class Membership < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :org
|
6
|
+
belongs_to :user
|
7
|
+
has_many :events
|
8
|
+
|
9
|
+
attr_datetime :expires_at
|
10
|
+
|
11
|
+
|
12
|
+
def any_permission?(*perms)
|
13
|
+
perms.any? do |p|
|
14
|
+
case p
|
15
|
+
when String
|
16
|
+
permissions.include? p
|
17
|
+
when Regexp
|
18
|
+
permissions.any?{|m| p =~ m}
|
19
|
+
else
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class Org < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :realm
|
6
|
+
has_many :events
|
7
|
+
has_many :memberships
|
8
|
+
|
9
|
+
attr :realm_id, :name, :state, :reference
|
10
|
+
attr_datetime :created_at
|
11
|
+
|
12
|
+
|
13
|
+
def users
|
14
|
+
memberships.map(&:user).compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_user(uid)
|
18
|
+
users.detect{|u| u.id == uid } || raise(RecordNotFound)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class Realm < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
has_many :app_hooks
|
6
|
+
has_many :events
|
7
|
+
has_many :login_policies
|
8
|
+
has_many :orgs
|
9
|
+
has_many :users
|
10
|
+
|
11
|
+
attr :api_key_policy, :api_key_prefix, :name, :require_unique_emails, :state
|
12
|
+
attr :username_validation_human
|
13
|
+
|
14
|
+
|
15
|
+
def reset!(params={})
|
16
|
+
parsed, _ = request(:post, "#{url}/reset", api_creds, params)
|
17
|
+
load(parsed)
|
18
|
+
errors.empty? ? self : false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class User < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :realm
|
6
|
+
has_many :events
|
7
|
+
has_many :memberships
|
8
|
+
|
9
|
+
attr :user_type, :username, :state, :reference
|
10
|
+
attr :first_name, :last_name, :password, :password_confirmation
|
11
|
+
attr :name, :api_key, :email
|
12
|
+
attr_datetime :created_at, :last_login_on
|
13
|
+
|
14
|
+
|
15
|
+
def orgs
|
16
|
+
memberships.map(&:org).compact
|
17
|
+
end
|
18
|
+
|
19
|
+
def find_org(id)
|
20
|
+
orgs.detect{|o| o.id == id } || raise(RecordNotFound)
|
21
|
+
end
|
22
|
+
|
23
|
+
def human? ; user_type=='human' ; end
|
24
|
+
def api? ; user_type=='api' ; end
|
25
|
+
|
26
|
+
|
27
|
+
class << self
|
28
|
+
|
29
|
+
def authenticate(username, password, params={}, api_creds=nil)
|
30
|
+
params = params.merge(password: password)
|
31
|
+
parsed, creds = request(:post, "#{url}/#{CGI.escape username}/authenticate", api_creds, params)
|
32
|
+
if parsed[:errors].any?
|
33
|
+
raise ValidationError, parsed[:errors]
|
34
|
+
end
|
35
|
+
new(parsed, creds)
|
36
|
+
end
|
37
|
+
|
38
|
+
def authenticate_key(api_key, params={}, api_creds=nil)
|
39
|
+
params = params.merge(api_key: api_key)
|
40
|
+
parsed, creds = request(:post, "#{url}/authenticate_key", api_creds, params)
|
41
|
+
if parsed[:errors].any?
|
42
|
+
raise ValidationError, parsed[:errors]
|
43
|
+
end
|
44
|
+
new(parsed, creds)
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_password_token(username, params={}, api_creds=nil)
|
48
|
+
parsed, creds = request(:post, "#{url}/#{CGI.escape username}/generate_password_token", api_creds, params)
|
49
|
+
if parsed[:errors].any?
|
50
|
+
raise ValidationError, parsed[:errors]
|
51
|
+
end
|
52
|
+
new(parsed, creds)
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset_password_with_token(username, token, new_pw, new_pw_2, params={}, api_creds=nil)
|
56
|
+
params = params.with_indifferent_access.merge(user: {token: token, password: new_pw, password_confirmation: new_pw_2})
|
57
|
+
parsed, creds = request(:post, "#{url}/#{CGI.escape username}/reset_password_with_token", api_creds, params)
|
58
|
+
if parsed[:errors].any?
|
59
|
+
raise ValidationError, parsed[:errors]
|
60
|
+
end
|
61
|
+
new(parsed, creds)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
# params - {current_password: 'old', password: 'new', password_confirmation: 'new'}
|
67
|
+
def update_password(params)
|
68
|
+
params = {user: params}
|
69
|
+
parsed, _ = request(:put, "#{url}/update_password", api_creds, params)
|
70
|
+
load(parsed)
|
71
|
+
errors.empty? ? self : false
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: authrocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thomas morgan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ncore
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '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'
|
55
|
+
description: AuthRocket client for Ruby.
|
56
|
+
email:
|
57
|
+
- tm@notioneer.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- authrocket.gemspec
|
68
|
+
- lib/authrocket.rb
|
69
|
+
- lib/authrocket/api/api_config.rb
|
70
|
+
- lib/authrocket/api/log_subscriber.rb
|
71
|
+
- lib/authrocket/api/railtie.rb
|
72
|
+
- lib/authrocket/api/version.rb
|
73
|
+
- lib/authrocket/app_hook.rb
|
74
|
+
- lib/authrocket/event.rb
|
75
|
+
- lib/authrocket/login_policy.rb
|
76
|
+
- lib/authrocket/membership.rb
|
77
|
+
- lib/authrocket/org.rb
|
78
|
+
- lib/authrocket/realm.rb
|
79
|
+
- lib/authrocket/user.rb
|
80
|
+
- lib/authrocket/user_token.rb
|
81
|
+
homepage: https://github.com/authrocket/authrocket-ruby
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.0.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: AuthRocket client for Ruby
|
105
|
+
test_files: []
|