credible 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/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +19 -0
- data/app/assets/config/credible_manifest.js +1 -0
- data/app/assets/stylesheets/credible/application.css +15 -0
- data/app/controllers/credible/application_controller.rb +43 -0
- data/app/controllers/credible/authentication/sessions_controller.rb +51 -0
- data/app/controllers/credible/authentication/users_controller.rb +91 -0
- data/app/controllers/credible/authentication_controller.rb +16 -0
- data/app/helpers/credible/application_helper.rb +4 -0
- data/app/jobs/credible/application_job.rb +4 -0
- data/app/mailers/credible/application_mailer.rb +6 -0
- data/app/mailers/credible/user_mailer.rb +21 -0
- data/app/models/credible/application_record.rb +5 -0
- data/app/policies/credible/application_policy.rb +61 -0
- data/app/policies/credible/authentication/session_policy.rb +9 -0
- data/app/policies/credible/authentication/user_policy.rb +17 -0
- data/app/policies/credible/authentication_policy.rb +16 -0
- data/app/views/credible/authentication/sessions/_session.json.jbuilder +5 -0
- data/app/views/credible/authentication/sessions/show.json.jbuilder +1 -0
- data/app/views/credible/authentication/users/_user.json.jbuilder +5 -0
- data/app/views/credible/authentication/users/show.json.jbuilder +1 -0
- data/app/views/credible/user_mailer/confirmation_email.html.haml +11 -0
- data/app/views/credible/user_mailer/confirmation_email.text.haml +9 -0
- data/app/views/credible/user_mailer/invitation_email.html.haml +3 -0
- data/app/views/credible/user_mailer/invitation_email.text.haml +6 -0
- data/config/initializers/warden.rb +65 -0
- data/config/routes.rb +22 -0
- data/lib/credible.rb +5 -0
- data/lib/credible/engine.rb +5 -0
- data/lib/credible/version.rb +3 -0
- data/lib/tasks/credible_tasks.rake +4 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d4f048f4ef29cbbf167e6425f4588cc58da3a57c6c4c42b460f13a486d47de1
|
4
|
+
data.tar.gz: 18f2f860fe62f1d597936c7b282231f9dfb9b3079b52d4a427bc9831447b8ca0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fd4f87bff69258e892b7591e41d223c57cb6806bfa5e1c60c893546a9dbc3adbcdf5c5788f82d3955ec5a527f378b8554cf212288430bdb61108caeaffa9cbc
|
7
|
+
data.tar.gz: f09499fb6fae982e693e4ab59f852bedc66a6dc66142a67bc89afbb81ac985bb573ac116832a65b22825a7290d6d15847feb4d085726487ba9ee2c3ce92c062c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Thom Bruce
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Credible
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'credible'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install credible
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Credible'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'rails/tasks/statistics.rake'
|
18
|
+
|
19
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/credible .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Credible
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
skip_before_action :verify_authenticity_token
|
4
|
+
|
5
|
+
include Pundit
|
6
|
+
after_action :verify_authorized
|
7
|
+
after_action :verify_policy_scoped, only: :index
|
8
|
+
|
9
|
+
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
10
|
+
rescue_from Pundit::NotDefinedError, with: :user_not_authorized
|
11
|
+
|
12
|
+
before_action :authenticate!, if: proc { request.env['HTTP_AUTHORIZATION'] || request.env['HTTP_API_TOKEN'] }
|
13
|
+
|
14
|
+
helper_method :current_user
|
15
|
+
helper_method :current_session
|
16
|
+
|
17
|
+
def pundit_user
|
18
|
+
current_session
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_user
|
22
|
+
current_session.user
|
23
|
+
end
|
24
|
+
|
25
|
+
def current_session
|
26
|
+
warden.user(:session) || Session.new(user: nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
def warden
|
30
|
+
request.env['warden']
|
31
|
+
end
|
32
|
+
|
33
|
+
def authenticate!
|
34
|
+
warden.authenticate!
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def user_not_authorized
|
40
|
+
render json: {}.to_json, status: :forbidden
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Credible::Authentication::SessionsController < Credible::AuthenticationController
|
2
|
+
before_action :set_session, only: [:show, :destroy]
|
3
|
+
|
4
|
+
skip_before_action :authenticate!, only: [:new, :create]
|
5
|
+
|
6
|
+
# GET /sessions
|
7
|
+
# GET /sessions.json
|
8
|
+
def index
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET /sessions/1
|
12
|
+
# GET /sessions/1.json
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /sessions/new
|
17
|
+
def new
|
18
|
+
@session = Session.new
|
19
|
+
authorize @session
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /sessions
|
23
|
+
# POST /sessions.json
|
24
|
+
def create
|
25
|
+
@session = Session.authenticate(permitted_attributes(Session))
|
26
|
+
authorize @session
|
27
|
+
|
28
|
+
if @session.save
|
29
|
+
render :show, status: :created, location: @session
|
30
|
+
else
|
31
|
+
render json: @session.errors, status: :unprocessable_entity
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# DELETE /sessions/1
|
36
|
+
# DELETE /sessions/1.json
|
37
|
+
# DELETE /sessions/current
|
38
|
+
# DELETE /sessions/current.json
|
39
|
+
def destroy
|
40
|
+
warden.logout
|
41
|
+
@session.destroy
|
42
|
+
head :no_content
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
# Use callbacks to share common setup or constraints between actions.
|
47
|
+
def set_session
|
48
|
+
@session = current_session
|
49
|
+
authorize @session
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
class Credible::Authentication::UsersController < Credible::AuthenticationController
|
2
|
+
before_action :set_user, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
skip_before_action :authenticate!, only: [:new, :create, :confirm]
|
5
|
+
|
6
|
+
# GET /users/1
|
7
|
+
# GET /users/1.json
|
8
|
+
def show
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET /users/new
|
12
|
+
def new
|
13
|
+
@user = User.new
|
14
|
+
authorize @user
|
15
|
+
end
|
16
|
+
|
17
|
+
# POST /users
|
18
|
+
# POST /users.json
|
19
|
+
def create
|
20
|
+
@user = User.new(permitted_attributes(User))
|
21
|
+
authorize @user
|
22
|
+
|
23
|
+
if @user.save
|
24
|
+
Credible::UserMailer.with(user: @user).confirmation_email.deliver_later
|
25
|
+
@session = Session.create(user: @user)
|
26
|
+
render :show, status: :created, location: @user
|
27
|
+
else
|
28
|
+
render json: @user.errors, status: :unprocessable_entity
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# GET /users/confirm/:confirmation_token
|
33
|
+
# GET /users/confirm/:confirmation_token.json
|
34
|
+
def confirm
|
35
|
+
@user = User.find_by(confirmation_token: params[:confirmation_token])
|
36
|
+
authorize @user
|
37
|
+
|
38
|
+
@user.confirm
|
39
|
+
|
40
|
+
if @user.save
|
41
|
+
@session = current_user ? current_session : Session.create(user: @user)
|
42
|
+
render :show, status: :created, location: @user
|
43
|
+
else
|
44
|
+
render json: @user.errors, status: :unprocessable_entity
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# POST /users/reset_password
|
49
|
+
# POST /users/reset_password.json
|
50
|
+
def reset_password
|
51
|
+
@user = User.find_by(email: permitted_attributes(User)[:email])
|
52
|
+
authorize @user
|
53
|
+
|
54
|
+
@user.reset_password
|
55
|
+
|
56
|
+
if @user.save
|
57
|
+
Credible::UserMailer.with(user: @user).confirmation_email.deliver_later
|
58
|
+
render :show, status: :ok, location: @user
|
59
|
+
else
|
60
|
+
render json: @user.errors, status: :unprocessable_entity
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# GET /users/1/edit
|
65
|
+
def edit
|
66
|
+
end
|
67
|
+
|
68
|
+
# PATCH/PUT /users/1
|
69
|
+
# PATCH/PUT /users/1.json
|
70
|
+
def update
|
71
|
+
if @user.update(permitted_attributes(@user))
|
72
|
+
render :show, status: :ok, location: @user
|
73
|
+
else
|
74
|
+
render json: @user.errors, status: :unprocessable_entity
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# DELETE /users/1
|
79
|
+
# DELETE /users/1.json
|
80
|
+
def destroy
|
81
|
+
@user.destroy
|
82
|
+
head :no_content
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
# Use callbacks to share common setup or constraints between actions.
|
87
|
+
def set_user
|
88
|
+
@user = current_user
|
89
|
+
authorize @user
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Credible::AuthenticationController < Credible::ApplicationController
|
2
|
+
# TODO: Authentication module is now redundant inside Credible Engine.
|
3
|
+
# Migrate out of namespace.
|
4
|
+
|
5
|
+
def policy_scope(scope)
|
6
|
+
super([:credible, :authentication, scope])
|
7
|
+
end
|
8
|
+
|
9
|
+
def authorize(record, query = nil)
|
10
|
+
super([:credible, :authentication, record], query)
|
11
|
+
end
|
12
|
+
|
13
|
+
def permitted_attributes(record, action = action_name)
|
14
|
+
super([:credible, :authentication, record], action)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Credible::UserMailer < Credible::ApplicationMailer
|
2
|
+
# TODO: Decouple from Settings in inheriting application.
|
3
|
+
# QUESTION: How then will we set the URL?
|
4
|
+
|
5
|
+
include Rails.application.routes.url_helpers
|
6
|
+
|
7
|
+
def confirmation_email
|
8
|
+
@settings = Settings.instance
|
9
|
+
@user = params[:user]
|
10
|
+
@url = root_url(host: @settings.hostname)
|
11
|
+
@confirmation_url = @url + 'confirm/' + @user.confirmation_token
|
12
|
+
mail(from: @settings.email, to: @user.email, subject: "Welcome to #{@settings.name} | Please confirm your account")
|
13
|
+
end
|
14
|
+
|
15
|
+
def invitation_email
|
16
|
+
@settings = Settings.instance
|
17
|
+
@user = params[:user]
|
18
|
+
@url = root_url(host: @settings.hostname)
|
19
|
+
mail(from: @settings.email, to: @user.email, subject: "You have been invited to #{@settings.name}")
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Credible
|
2
|
+
class ApplicationPolicy
|
3
|
+
attr_reader :session, :record
|
4
|
+
|
5
|
+
def initialize(session, record)
|
6
|
+
@session = session
|
7
|
+
@record = record
|
8
|
+
end
|
9
|
+
|
10
|
+
def index?
|
11
|
+
user
|
12
|
+
end
|
13
|
+
|
14
|
+
def show?
|
15
|
+
user
|
16
|
+
end
|
17
|
+
|
18
|
+
def create?
|
19
|
+
user
|
20
|
+
end
|
21
|
+
|
22
|
+
def new?
|
23
|
+
create?
|
24
|
+
end
|
25
|
+
|
26
|
+
def update?
|
27
|
+
user
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit?
|
31
|
+
update?
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy?
|
35
|
+
user
|
36
|
+
end
|
37
|
+
|
38
|
+
# Helper Methods
|
39
|
+
def user
|
40
|
+
session.user
|
41
|
+
end
|
42
|
+
|
43
|
+
class Scope
|
44
|
+
attr_reader :session, :scope
|
45
|
+
|
46
|
+
def initialize(session, scope)
|
47
|
+
@session = session
|
48
|
+
@scope = scope
|
49
|
+
end
|
50
|
+
|
51
|
+
def resolve
|
52
|
+
scope.all
|
53
|
+
end
|
54
|
+
|
55
|
+
# Helper Methods
|
56
|
+
def user
|
57
|
+
session.user
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Credible::Authentication::UserPolicy < Credible::AuthenticationPolicy
|
2
|
+
def permitted_attributes
|
3
|
+
[:name, :email, :password]
|
4
|
+
end
|
5
|
+
|
6
|
+
def confirm?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset_password?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def update?
|
15
|
+
user && user == record
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Credible::AuthenticationPolicy < Credible::ApplicationPolicy
|
2
|
+
# Authentication concerns the User and their single instance.
|
3
|
+
# The rules that apply to update? will always apply to show?
|
4
|
+
# and destroy? too.
|
5
|
+
def show?
|
6
|
+
update?
|
7
|
+
end
|
8
|
+
|
9
|
+
def create?
|
10
|
+
!user
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy?
|
14
|
+
update?
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "session", session: @session
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "user", user: @user
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%h1= "Welcome to #{@settings.name}, #{@user.name}"
|
2
|
+
|
3
|
+
%p
|
4
|
+
= "You have successfully signed up to #{@settings.name}, your username is: #{@user.email}."
|
5
|
+
%br/
|
6
|
+
|
7
|
+
%p
|
8
|
+
To confirm your account, please follow this link:
|
9
|
+
= link_to @confirmation_url, @confirmation_url
|
10
|
+
|
11
|
+
%p Thanks for joining and have a great day!
|
@@ -0,0 +1,9 @@
|
|
1
|
+
= "Welcome to #{@settings.name}, #{@user.name}"
|
2
|
+
\===============================================
|
3
|
+
|
4
|
+
= "You have successfully signed up to #{@settings.name}, your username is: #{@user.email}."
|
5
|
+
|
6
|
+
To confirm your account, please follow this link:
|
7
|
+
= @confirmation_url
|
8
|
+
|
9
|
+
Thanks for joining and have a great day!
|
@@ -0,0 +1,65 @@
|
|
1
|
+
Rails.application.config.middleware.use Warden::Manager do |config|
|
2
|
+
config.failure_app = ->(env) { SessionsController.action(:new).call(env) } # TODO: Fix me.
|
3
|
+
|
4
|
+
config.default_scope = :session
|
5
|
+
|
6
|
+
config.scope_defaults :session, store: false, strategies: [:jwt, :api_token]
|
7
|
+
end
|
8
|
+
|
9
|
+
# TODO: See here for how Devise initializes Warden: https://github.com/heartcombo/devise/blob/715192a7709a4c02127afb067e66230061b82cf2/lib/devise/rails.rb
|
10
|
+
# It's also worth perusing the mention of 'warden' in the Devise repo. Interesting strategies at work.
|
11
|
+
|
12
|
+
Warden::Strategies.add(:jwt) do
|
13
|
+
def valid?
|
14
|
+
env['HTTP_AUTHORIZATION']
|
15
|
+
end
|
16
|
+
|
17
|
+
def env
|
18
|
+
request.env
|
19
|
+
end
|
20
|
+
|
21
|
+
def authenticate!
|
22
|
+
begin
|
23
|
+
pattern = /^Bearer /
|
24
|
+
header = env['HTTP_AUTHORIZATION']
|
25
|
+
jwt = header.gsub(pattern, '') if header && header.match(pattern)
|
26
|
+
token =
|
27
|
+
JWT.decode jwt, Rails.application.secrets.secret_key_base, true,
|
28
|
+
iss: 'Helvellyn', verify_iss: true, algorithm: 'HS256' # [1]
|
29
|
+
rescue JWT::InvalidIssuerError
|
30
|
+
fail!('Could not authenticate')
|
31
|
+
end
|
32
|
+
|
33
|
+
session = Session.find(token[0]['data']['session_id'])
|
34
|
+
|
35
|
+
session ? success!(session) : fail!('Could not authenticate')
|
36
|
+
end
|
37
|
+
|
38
|
+
def store?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Warden::Strategies.add(:api_token) do
|
44
|
+
def valid?
|
45
|
+
request.env['HTTP_API_TOKEN']
|
46
|
+
end
|
47
|
+
|
48
|
+
def env
|
49
|
+
request.env
|
50
|
+
end
|
51
|
+
|
52
|
+
def authenticate!
|
53
|
+
session = Session.find_by(token: env['HTTP_API_TOKEN'])
|
54
|
+
session ? success!(session) : fail!('Could not authenticate')
|
55
|
+
end
|
56
|
+
|
57
|
+
def store?
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# [1] Use of `secrets` instead of `credentials` makes for a container-ready deploy on Heroku (easier setup for open source)
|
63
|
+
# Now that we've transitioned into an Engine, though, we should...
|
64
|
+
# TODO: Use credentials if credentials is present, use secrets if secrets is present.
|
65
|
+
# Take a look at how devise achieves the same thing.
|
data/config/routes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Credible::Engine.routes.draw do
|
2
|
+
scope module: 'authentication', format: false, defaults: { format: 'json' } do
|
3
|
+
# /auth/login.json
|
4
|
+
post 'login', to: 'sessions#create'
|
5
|
+
# /auth/reset_password.json
|
6
|
+
post 'reset_password', to: 'users#reset_password'
|
7
|
+
# /auth/signup.json
|
8
|
+
post 'signup', to: 'users#create'
|
9
|
+
# /auth/confirm.json
|
10
|
+
get 'confirm/:confirmation_token', to: 'users#confirm'
|
11
|
+
# /auth/signout.json
|
12
|
+
delete 'signout', to: 'sessions#destroy'
|
13
|
+
|
14
|
+
# /auth/account/**/*.json
|
15
|
+
scope '/account' do
|
16
|
+
# /auth/account/sessions/*.json
|
17
|
+
resources :sessions, except: [:new, :create, :edit, :update]
|
18
|
+
# /auth/account/*.json
|
19
|
+
resource :user, path: '', except: [:new, :create]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/credible.rb
ADDED
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: credible
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thom Bruce
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.2
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 6.0.2.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.0.2
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 6.0.2.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: warden
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.2.8
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.2.8
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pundit
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.1.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.1.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: pg
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 4.0.0.beta3
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 4.0.0.beta3
|
89
|
+
description: Provides token-based authentication for Rails API apps.
|
90
|
+
email:
|
91
|
+
- thom@thombruce.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- MIT-LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- app/assets/config/credible_manifest.js
|
100
|
+
- app/assets/stylesheets/credible/application.css
|
101
|
+
- app/controllers/credible/application_controller.rb
|
102
|
+
- app/controllers/credible/authentication/sessions_controller.rb
|
103
|
+
- app/controllers/credible/authentication/users_controller.rb
|
104
|
+
- app/controllers/credible/authentication_controller.rb
|
105
|
+
- app/helpers/credible/application_helper.rb
|
106
|
+
- app/jobs/credible/application_job.rb
|
107
|
+
- app/mailers/credible/application_mailer.rb
|
108
|
+
- app/mailers/credible/user_mailer.rb
|
109
|
+
- app/models/credible/application_record.rb
|
110
|
+
- app/policies/credible/application_policy.rb
|
111
|
+
- app/policies/credible/authentication/session_policy.rb
|
112
|
+
- app/policies/credible/authentication/user_policy.rb
|
113
|
+
- app/policies/credible/authentication_policy.rb
|
114
|
+
- app/views/credible/authentication/sessions/_session.json.jbuilder
|
115
|
+
- app/views/credible/authentication/sessions/show.json.jbuilder
|
116
|
+
- app/views/credible/authentication/users/_user.json.jbuilder
|
117
|
+
- app/views/credible/authentication/users/show.json.jbuilder
|
118
|
+
- app/views/credible/user_mailer/confirmation_email.html.haml
|
119
|
+
- app/views/credible/user_mailer/confirmation_email.text.haml
|
120
|
+
- app/views/credible/user_mailer/invitation_email.html.haml
|
121
|
+
- app/views/credible/user_mailer/invitation_email.text.haml
|
122
|
+
- config/initializers/warden.rb
|
123
|
+
- config/routes.rb
|
124
|
+
- lib/credible.rb
|
125
|
+
- lib/credible/engine.rb
|
126
|
+
- lib/credible/version.rb
|
127
|
+
- lib/tasks/credible_tasks.rake
|
128
|
+
homepage: https://thombruce.com/
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubygems_version: 3.0.8
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Rails token auth
|
151
|
+
test_files: []
|