strongmind-auth 1.0.12 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/jwt_utilities.rb +1 -1
- data/app/controllers/concerns/strong_mind_nav.rb +3 -1
- data/app/controllers/users/omniauth_callbacks_controller.rb +2 -0
- data/app/controllers/users/sessions_controller.rb +0 -2
- data/lib/generators/strongmind/install_generator.rb +3 -0
- data/lib/strongmind/auth/version.rb +1 -1
- data/lib/strongmind/common_nav_fetcher.rb +6 -12
- data/lib/strongmind/exceptions.rb +9 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc46e88e501287e0a5cc68e2955f02bdbc57846ddb57d857c9bb4a059d7b575e
|
4
|
+
data.tar.gz: 2c0975de9ae802db081741d997486478203fd53664a099711842fbf5ce94054b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ed12a69efd46d42d554b2f1943de7c4915889a24b4aa589acf9649fab081c429bd0e9b0e655c027f3f7921df3da25cdafbae82b7887ed765b33d967f1eec0f7
|
7
|
+
data.tar.gz: a0a0d134a2ec866ca987498cb10c766f9b746c60dcf852d028cec7cd70b7b326e2c5a3642fde99fcfac7c20d397c609a3ff8e686c756d7e7018ddc6a2620696b
|
@@ -72,7 +72,7 @@ module JwtUtilities
|
|
72
72
|
def validate_tokens(tokens)
|
73
73
|
return unless tokens[:error] == 'invalid_grant' || !tokens[:refresh_token]
|
74
74
|
|
75
|
-
raise RefreshTokenExpired, tokens[:error]
|
75
|
+
raise Strongmind::Exceptions::RefreshTokenExpired, tokens[:error]
|
76
76
|
end
|
77
77
|
|
78
78
|
def generate_tokens(session_data)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "strongmind/common_nav_fetcher"
|
2
|
+
require "strongmind/exceptions"
|
2
3
|
|
3
4
|
module StrongMindNav
|
4
5
|
extend ActiveSupport::Concern
|
@@ -10,7 +11,7 @@ module StrongMindNav
|
|
10
11
|
@top_navbar_html = navbar[:top_navbar_html]
|
11
12
|
@bottom_navbar_html = navbar[:bottom_navbar_html]
|
12
13
|
@theme_css = navbar[:theme_css]
|
13
|
-
rescue Strongmind::
|
14
|
+
rescue Strongmind::Exceptions::TokenNotFoundError, Strongmind::Exceptions::UserNotFoundError => e
|
14
15
|
Sentry.capture_exception(e)
|
15
16
|
Rails.logger.error(e)
|
16
17
|
flash[:alert] = e.inspect if Rails.env.development?
|
@@ -18,6 +19,7 @@ module StrongMindNav
|
|
18
19
|
render 'logins/index'
|
19
20
|
rescue Exception => e
|
20
21
|
Sentry.capture_exception(e)
|
22
|
+
Rails.logger.error(e)
|
21
23
|
@top_navbar_html = render_to_string(partial: 'layouts/loading_navbar').html_safe
|
22
24
|
end
|
23
25
|
end
|
@@ -10,6 +10,8 @@ module Users
|
|
10
10
|
User.auth_token_cache = auth
|
11
11
|
@user = User.with_credentials(auth)
|
12
12
|
|
13
|
+
render plain: "You do not have permission to access this application.", status: :unauthorized and return if @user.nil?
|
14
|
+
|
13
15
|
session[:refresh_token] = request.env['omniauth.auth'].credentials['refresh_token']
|
14
16
|
flash.delete(:notice)
|
15
17
|
|
@@ -12,6 +12,9 @@ module Strongmind
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def protect_app_files_and_add_nav
|
15
|
+
inject_into_file "app/controllers/application_controller.rb", before: "class ApplicationController < ActionController::Base\n" do
|
16
|
+
"require \"strongmind/exceptions\"\n\n"
|
17
|
+
end
|
15
18
|
inject_into_file "app/controllers/application_controller.rb", after: "class ApplicationController < ActionController::Base\n" do
|
16
19
|
" include StrongMindNav
|
17
20
|
before_action :authenticate_user!
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
require "strongmind/exceptions"
|
3
3
|
require 'platform_sdk'
|
4
4
|
|
5
5
|
module Strongmind
|
@@ -9,12 +9,8 @@ module Strongmind
|
|
9
9
|
|
10
10
|
include Rails.application.routes.url_helpers
|
11
11
|
|
12
|
-
class TokenNotFoundError < StandardError; end
|
13
|
-
|
14
|
-
class UserNotFoundError < StandardError; end
|
15
|
-
|
16
12
|
def initialize(user, request)
|
17
|
-
raise UserNotFoundError, 'User not found' unless user.present?
|
13
|
+
raise Strongmind::Exceptions::UserNotFoundError, 'User not found' unless user.present?
|
18
14
|
raise ArgumentError, 'Request not found' unless request.present?
|
19
15
|
|
20
16
|
@user = user
|
@@ -54,7 +50,7 @@ module Strongmind
|
|
54
50
|
cache_data = Rails.cache.fetch(user.uid)
|
55
51
|
cache_missing_message = " - check your caching settings (switch to file or redis)" if Rails.env.development?
|
56
52
|
unless cache_data&.key?(:access_token)
|
57
|
-
raise TokenNotFoundError, "Token not found for user #{user.uid}#{cache_missing_message}"
|
53
|
+
raise Strongmind::Exceptions::TokenNotFoundError, "Token not found for user #{user.uid}#{cache_missing_message}"
|
58
54
|
end
|
59
55
|
|
60
56
|
cache_data[:access_token]
|
@@ -83,14 +79,12 @@ module Strongmind
|
|
83
79
|
end
|
84
80
|
|
85
81
|
def nav_item_data(item)
|
86
|
-
url =
|
82
|
+
url = item[:url]
|
87
83
|
{
|
88
84
|
name: item[:name],
|
89
85
|
icon: item[:icon],
|
90
|
-
url
|
91
|
-
|
92
|
-
is_active: current_page?(url),
|
93
|
-
is_external: false
|
86
|
+
url: url,
|
87
|
+
is_active: current_page?(url)
|
94
88
|
}
|
95
89
|
end
|
96
90
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongmind-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Belding
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/strongmind/auth/engine.rb
|
129
129
|
- lib/strongmind/auth/version.rb
|
130
130
|
- lib/strongmind/common_nav_fetcher.rb
|
131
|
+
- lib/strongmind/exceptions.rb
|
131
132
|
- lib/tasks/rails/auth_tasks.rake
|
132
133
|
- lib/tasks/strongmind/auth_tasks.rake
|
133
134
|
homepage: https://www.strongmind.com
|