client_manager 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/README.md +128 -0
- data/Rakefile +37 -0
- data/app/assets/config/client_manager_manifest.js +2 -0
- data/app/assets/javascripts/client_manager/application.js +16 -0
- data/app/assets/javascripts/client_manager/clipboard.min.js +7 -0
- data/app/assets/javascripts/client_manager/oneui.min.js +5 -0
- data/app/assets/javascripts/client_manager/passwords.js +2 -0
- data/app/assets/javascripts/client_manager/sessions.js +2 -0
- data/app/assets/javascripts/client_manager/users.js +2 -0
- data/app/assets/stylesheets/client_manager/application.css +17 -0
- data/app/assets/stylesheets/client_manager/bootstrap.min.css +5 -0
- data/app/assets/stylesheets/client_manager/custom.css +23 -0
- data/app/assets/stylesheets/client_manager/oneui.min.css +4 -0
- data/app/assets/stylesheets/client_manager/passwords.css +4 -0
- data/app/assets/stylesheets/client_manager/sessions.css +4 -0
- data/app/assets/stylesheets/client_manager/users.css +4 -0
- data/app/controllers/client_manager/application_controller.rb +31 -0
- data/app/controllers/client_manager/clients_controller.rb +46 -0
- data/app/controllers/client_manager/concerns/set_client_by_token.rb +40 -0
- data/app/controllers/client_manager/passwords_controller.rb +26 -0
- data/app/controllers/client_manager/sessions_controller.rb +38 -0
- data/app/controllers/client_manager/users_controller.rb +121 -0
- data/app/helpers/client_manager/application_helper.rb +5 -0
- data/app/helpers/client_manager/passwords_helper.rb +4 -0
- data/app/helpers/client_manager/sessions_helper.rb +4 -0
- data/app/helpers/client_manager/users_helper.rb +4 -0
- data/app/jobs/client_manager/application_job.rb +4 -0
- data/app/mailers/client_manager/application_mailer.rb +6 -0
- data/app/mailers/client_manager/registration_mailer.rb +12 -0
- data/app/models/client_manager/application_record.rb +5 -0
- data/app/models/client_manager/client.rb +33 -0
- data/app/models/client_manager/user.rb +42 -0
- data/app/views/client_manager/clients/index.html.erb +37 -0
- data/app/views/client_manager/clients/new.html.erb +27 -0
- data/app/views/client_manager/clients/show.html.erb +41 -0
- data/app/views/client_manager/passwords/change.html.erb +46 -0
- data/app/views/client_manager/registration_mailer/registration_email.html.erb +90 -0
- data/app/views/client_manager/sessions/login.html.erb +53 -0
- data/app/views/client_manager/users/edit.html.erb +55 -0
- data/app/views/client_manager/users/index.html.erb +53 -0
- data/app/views/client_manager/users/new.html.erb +39 -0
- data/app/views/layouts/client_manager/application.html.erb +20 -0
- data/app/views/layouts/client_manager/none.html.erb +1 -0
- data/app/views/layouts/client_manager/partials/_header.html.erb +40 -0
- data/app/views/layouts/client_manager/partials/_modal.html.erb +15 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20160816183756_create_client_manager_users.rb +11 -0
- data/db/migrate/20160822112804_create_client_manager_clients.rb +11 -0
- data/db/migrate/20160905184226_add_password_digest_to_user.rb +5 -0
- data/db/migrate/20160930152731_add_password_changed_flag_to_users.rb +5 -0
- data/db/migrate/20161007235114_add_super_admin_flag_to_users.rb +5 -0
- data/lib/client_manager.rb +5 -0
- data/lib/client_manager/engine.rb +32 -0
- data/lib/client_manager/version.rb +3 -0
- data/lib/generators/client_manager/install_generator.rb +107 -0
- data/lib/generators/client_manager/templates/client_manager.rb +3 -0
- data/lib/tasks/client_manager_tasks.rake +12 -0
- metadata +217 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
module ClientManager
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
require 'jquery-rails'
|
4
|
+
require 'growlyflash'
|
5
|
+
require 'font-awesome-rails'
|
6
|
+
require 'bcrypt'
|
7
|
+
require 'jwt'
|
8
|
+
|
9
|
+
isolate_namespace ClientManager
|
10
|
+
|
11
|
+
|
12
|
+
initializer "client_manager", before: :load_config_initializers do |app|
|
13
|
+
Rails.application.routes.append do
|
14
|
+
mount ClientManager::Engine, at: "/client_manager"
|
15
|
+
end
|
16
|
+
|
17
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
18
|
+
Rails.application.config.paths["db/migrate"] << expanded_path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
mattr_accessor :token_secret
|
25
|
+
self.token_secret = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.setup(&block)
|
29
|
+
yield self
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module ClientManager
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def create_initializer_file
|
12
|
+
copy_file 'client_manager.rb', 'config/initializers/client_manager.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def include_controller_concerns
|
17
|
+
fname = "app/controllers/application_controller.rb"
|
18
|
+
line = "include ClientManager::Concerns::SetClientByToken"
|
19
|
+
|
20
|
+
if File.exist?(File.join(destination_root, fname))
|
21
|
+
if parse_file_for_line(fname, line)
|
22
|
+
say_status("skipped", "Concern is already included in the application controller.")
|
23
|
+
elsif is_rails_api?
|
24
|
+
inject_into_file fname, after: "class ApplicationController < ActionController::API\n" do
|
25
|
+
<<-'RUBY'
|
26
|
+
include ClientManager::Concerns::SetClientByToken
|
27
|
+
RUBY
|
28
|
+
end
|
29
|
+
else
|
30
|
+
inject_into_file fname, after: "class ApplicationController < ActionController::Base\n" do
|
31
|
+
<<-'RUBY'
|
32
|
+
include ClientManager::Concerns::SetClientByToken
|
33
|
+
RUBY
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
say_status("skipped", "app/controllers/application_controller.rb not found. Add 'include ClientManager::Concerns::SetClientByToken' to any controllers that require authentication.")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def ignore_mailer_failure
|
42
|
+
application do
|
43
|
+
"config.action_mailer.raise_delivery_errors = false"
|
44
|
+
end
|
45
|
+
say_status("insert", "config/application.rb")
|
46
|
+
end
|
47
|
+
|
48
|
+
def convert_api_only_to_normal
|
49
|
+
if is_rails_api?
|
50
|
+
add_action_dispatch_to_application
|
51
|
+
require_sprockets_railtie
|
52
|
+
remove_api_only_declaration
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
|
59
|
+
def add_action_dispatch_to_application
|
60
|
+
application do
|
61
|
+
"config.middleware.use ActionDispatch::Flash"
|
62
|
+
end
|
63
|
+
say_status("insert", "config/application.rb")
|
64
|
+
end
|
65
|
+
|
66
|
+
def require_sprockets_railtie
|
67
|
+
fname = "config/application.rb"
|
68
|
+
|
69
|
+
if File.exist?(File.join(destination_root, fname))
|
70
|
+
gsub_file 'config/application.rb', '# require "sprockets/railtie"', 'require "sprockets/railtie"'
|
71
|
+
else
|
72
|
+
say_status("skipped", "application.rb not found, cannot add sprockets")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def remove_api_only_declaration
|
77
|
+
fname = "config/application.rb"
|
78
|
+
|
79
|
+
if File.exist?(File.join(destination_root, fname))
|
80
|
+
gsub_file 'config/application.rb', 'config.api_only = true', ''
|
81
|
+
else
|
82
|
+
say_status("skipped", "application.rb not found")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def parse_file_for_line(filename, str)
|
88
|
+
match = false
|
89
|
+
|
90
|
+
File.open(File.join(destination_root, filename)) do |f|
|
91
|
+
f.each_line do |line|
|
92
|
+
if line =~ /(#{Regexp.escape(str)})/mi
|
93
|
+
match = line
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
match
|
98
|
+
end
|
99
|
+
|
100
|
+
def is_rails_api?
|
101
|
+
fname = "app/controllers/application_controller.rb"
|
102
|
+
line = "class ApplicationController < ActionController::API"
|
103
|
+
parse_file_for_line(fname, line)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :client_manager do
|
2
|
+
desc "Creates new superadmin. Usage: client_manager:superadmin NAME=Test EMAIL=test@test.com PASSWORD=password"
|
3
|
+
task superadmin: :environment do
|
4
|
+
name = ENV['NAME'].to_s
|
5
|
+
email = ENV['EMAIL'].to_s
|
6
|
+
password = ENV['PASSWORD'].to_s
|
7
|
+
if (ClientManager::User.create_superadmin(name, email, password))
|
8
|
+
puts "Super admin created successfully"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: client_manager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timi Ajiboye
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-11 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: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: growlyflash
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sass-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: font-awesome-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jquery-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bcrypt
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: jwt
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: This gem provides views to add users (probably front-end or mobile developers)
|
126
|
+
to your Rails 5 so they can create clients and manage tokens. With this, you can
|
127
|
+
authenticate all requests and eventually track usage by each client.
|
128
|
+
email:
|
129
|
+
- timi@helloworld.ng
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- README.md
|
135
|
+
- Rakefile
|
136
|
+
- app/assets/config/client_manager_manifest.js
|
137
|
+
- app/assets/javascripts/client_manager/application.js
|
138
|
+
- app/assets/javascripts/client_manager/clipboard.min.js
|
139
|
+
- app/assets/javascripts/client_manager/oneui.min.js
|
140
|
+
- app/assets/javascripts/client_manager/passwords.js
|
141
|
+
- app/assets/javascripts/client_manager/sessions.js
|
142
|
+
- app/assets/javascripts/client_manager/users.js
|
143
|
+
- app/assets/stylesheets/client_manager/application.css
|
144
|
+
- app/assets/stylesheets/client_manager/bootstrap.min.css
|
145
|
+
- app/assets/stylesheets/client_manager/custom.css
|
146
|
+
- app/assets/stylesheets/client_manager/oneui.min.css
|
147
|
+
- app/assets/stylesheets/client_manager/passwords.css
|
148
|
+
- app/assets/stylesheets/client_manager/sessions.css
|
149
|
+
- app/assets/stylesheets/client_manager/users.css
|
150
|
+
- app/controllers/client_manager/application_controller.rb
|
151
|
+
- app/controllers/client_manager/clients_controller.rb
|
152
|
+
- app/controllers/client_manager/concerns/set_client_by_token.rb
|
153
|
+
- app/controllers/client_manager/passwords_controller.rb
|
154
|
+
- app/controllers/client_manager/sessions_controller.rb
|
155
|
+
- app/controllers/client_manager/users_controller.rb
|
156
|
+
- app/helpers/client_manager/application_helper.rb
|
157
|
+
- app/helpers/client_manager/passwords_helper.rb
|
158
|
+
- app/helpers/client_manager/sessions_helper.rb
|
159
|
+
- app/helpers/client_manager/users_helper.rb
|
160
|
+
- app/jobs/client_manager/application_job.rb
|
161
|
+
- app/mailers/client_manager/application_mailer.rb
|
162
|
+
- app/mailers/client_manager/registration_mailer.rb
|
163
|
+
- app/models/client_manager/application_record.rb
|
164
|
+
- app/models/client_manager/client.rb
|
165
|
+
- app/models/client_manager/user.rb
|
166
|
+
- app/views/client_manager/clients/index.html.erb
|
167
|
+
- app/views/client_manager/clients/new.html.erb
|
168
|
+
- app/views/client_manager/clients/show.html.erb
|
169
|
+
- app/views/client_manager/passwords/change.html.erb
|
170
|
+
- app/views/client_manager/registration_mailer/registration_email.html.erb
|
171
|
+
- app/views/client_manager/sessions/login.html.erb
|
172
|
+
- app/views/client_manager/users/edit.html.erb
|
173
|
+
- app/views/client_manager/users/index.html.erb
|
174
|
+
- app/views/client_manager/users/new.html.erb
|
175
|
+
- app/views/layouts/client_manager/application.html.erb
|
176
|
+
- app/views/layouts/client_manager/none.html.erb
|
177
|
+
- app/views/layouts/client_manager/partials/_header.html.erb
|
178
|
+
- app/views/layouts/client_manager/partials/_modal.html.erb
|
179
|
+
- config/locales/devise.en.yml
|
180
|
+
- config/routes.rb
|
181
|
+
- db/migrate/20160816183756_create_client_manager_users.rb
|
182
|
+
- db/migrate/20160822112804_create_client_manager_clients.rb
|
183
|
+
- db/migrate/20160905184226_add_password_digest_to_user.rb
|
184
|
+
- db/migrate/20160930152731_add_password_changed_flag_to_users.rb
|
185
|
+
- db/migrate/20161007235114_add_super_admin_flag_to_users.rb
|
186
|
+
- lib/client_manager.rb
|
187
|
+
- lib/client_manager/engine.rb
|
188
|
+
- lib/client_manager/version.rb
|
189
|
+
- lib/generators/client_manager/install_generator.rb
|
190
|
+
- lib/generators/client_manager/templates/client_manager.rb
|
191
|
+
- lib/tasks/client_manager_tasks.rake
|
192
|
+
homepage: https://github.com/timigod/client-manager
|
193
|
+
licenses:
|
194
|
+
- MIT
|
195
|
+
metadata: {}
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubyforge_project:
|
212
|
+
rubygems_version: 2.4.5.1
|
213
|
+
signing_key:
|
214
|
+
specification_version: 4
|
215
|
+
summary: Simple gem/engine to manage clients and their tokens for your Rails 5 API.
|
216
|
+
test_files: []
|
217
|
+
has_rdoc:
|