Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_api_authentication
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
rails_api_authentication
Commits
38a6dda4
Commit
38a6dda4
authored
May 02, 2017
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refector the include method
parent
6fabc153
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
0 deletions
+57
-0
rails_api_authentication.rb
lib/rails_api_authentication.rb
+23
-0
acts_as_authentication_handler.rb
...ails_api_authentication/acts_as_authentication_handler.rb
+13
-0
acts_as_authenticationable.rb
lib/rails_api_authentication/acts_as_authenticationable.rb
+8
-0
configuration.rb
lib/rails_api_authentication/configuration.rb
+13
-0
No files found.
lib/rails_api_authentication.rb
View file @
38a6dda4
require
"rails_api_authentication/version"
require
"rails_api_authentication/configuration"
require
"rails_api_authentication/auth_action"
require
"rails_api_authentication/auth_session"
require
"rails_api_authentication/auth_token"
require
"rails_api_authentication/authable"
require
"rails_api_authentication/acts_as_authenticationable"
require
"rails_api_authentication/acts_as_authentication_handler"
module
RailsApiAuthentication
extend
Configuration
private
def
self
.
ensure_models_can_act_as_token_authenticatables
model_adapters
model_adapters
.
each
do
|
model_adapter
|
model_adapter
.
base_class
.
send
:extend
,
RailsApiAuthentication
::
ActsAsAuthenticationable
end
end
def
self
.
ensure_controllers_can_act_as_token_authentication_handlers
controller_adapters
controller_adapters
.
each
do
|
controller_adapter
|
controller_adapter
.
base_class
.
send
:extend
,
RailsApiAuthentication
::
ActsAsAuthenticationHandler
end
end
available_model_adapters
=
load_available_adapters
RailsApiAuthentication
.
model_adapters
ensure_models_can_act_as_token_authenticatables
available_model_adapters
available_controller_adapters
=
load_available_adapters
RailsApiAuthentication
.
controller_adapters
ensure_controllers_can_act_as_token_authentication_handlers
available_controller_adapters
end
lib/rails_api_authentication/acts_as_authentication_handler.rb
0 → 100644
View file @
38a6dda4
module
RailsApiAuthentication
module
ActsAsAuthenticationHandler
def
acts_as_auth_action
(
klass_sym
,
options
=
{})
include
RailsApiAuthentication
::
AuthAction
auth_action
klass_sym
,
options
end
def
acts_as_auth_session
(
klass_sym
)
include
RailsApiAuthentication
::
AuthSession
auth_session
klass_sym
end
end
end
lib/rails_api_authentication/acts_as_authenticationable.rb
0 → 100644
View file @
38a6dda4
module
RailsApiAuthentication
module
ActsAsAuthenticationable
def
acts_as_authentication
(
params
=
{})
include
RailsApiAuthentication
::
Authable
auth_for
params
end
end
end
lib/rails_api_authentication/configuration.rb
0 → 100644
View file @
38a6dda4
module
RailsApiAuthentication
module
Configuration
mattr_accessor
:controller_adapters
mattr_accessor
:model_adapters
@@model_adapters
=
[
'active_record'
,
'mongoid'
]
@@adapters_dependencies
=
{
'active_record'
=>
'ActiveRecord::Base'
,
'mongoid'
=>
'Mongoid::Document'
,
'rails'
=>
'ActionController::Base'
,
'rails_api'
=>
'ActionController::API'
,
'rails_metal'
=>
'ActionController::Metal'
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment