Skip to content

Commit b4ca8fe

Browse files
authored
Merge pull request #31 from RadiusNetworks/minor-fixes-deprecations
Minor fixes deprecations
2 parents 0c8a156 + e511a6e commit b4ca8fe

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

app/controllers/kracken/sessions_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def create
1313

1414
def destroy
1515
reset_session
16-
flash[:notice] = "Signed out successfully."
1716
redirect_to "#{provider_url}/users/sign_out#{signout_redirect_query}"
1817
end
1918

lib/kracken/controllers/token_authenticatable.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ def current_user_id
148148
# transfer the knowledge about also checking for the params.
149149
def munge_header_auth_token!
150150
return unless params[:token]
151+
deprecation = ActiveSupport::Deprecation.new("1.0", "kracken")
152+
deprecation.behavior = ActiveSupport::Deprecation.behavior
153+
deprecation.silenced = ActiveSupport::Deprecation.silenced
154+
controller_action = "#{request.controller_class}#" \
155+
"#{request.path_parameters[:action] || :index}"
156+
deprecation.warn "[#{controller_action}][kracken] Passing auth " \
157+
"tokens as query parameters is deprecated. This is insecure and " \
158+
"will be removed in a future version of Kracken. Use the " \
159+
"'Authorization' header instead."
151160
request.env['HTTP_AUTHORIZATION'] = "Token token=\"#{params[:token]}\""
152161
end
153162

lib/kracken/json_api/public_exceptions.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def log_error(env, wrapper)
1515
trace = wrapper.framework_trace if trace.empty?
1616

1717
ActiveSupport::Deprecation.silence do
18-
message = "\n#{exception.class} (#{exception.message}):\n"
18+
# After Ruby 2.2.3 support change `String.new` to `+` literal
19+
message = String.new("\n#{exception.class} (#{exception.message}):\n")
1920
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
2021
message << " " << trace.join("\n ")
2122
logger.fatal("#{message}\n\n")

lib/kracken/rspec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def authenticate_user_with_token!
8282

8383
c.before do
8484
Kracken::Controllers::TokenAuthenticatable.clear_auth_cache
85+
Kracken::Authenticator.cache.clear
8586
Kracken::SpecHelper.current_user = nil
8687
end
8788
end

spec/kracken/controllers/token_authenticatable_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def authenticate_or_request_with_http_token(realm = nil)
3636
a_controller.params = { token: expected_token }
3737

3838
expect {
39-
a_controller.authenticate_user_with_token!
39+
ActiveSupport::Deprecation.silence do
40+
a_controller.authenticate_user_with_token!
41+
end
4042
}.to change {
4143
a_controller.request.env
4244
}.from(

spec/support/base_controller_double.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
module Kracken
44
class BaseControllerDouble
5-
Request = Struct.new(:env)
5+
Request = Struct.new(:env, :controller_class, :path_parameters)
66

77
attr_accessor :session, :cookies, :request, :params
88

99
def initialize
1010
@session = {}
1111
@cookies = {}
12-
@request = Request.new({})
13-
@params = {}
12+
@params = { action: :index }
13+
@request = Request.new({}, self.class, @params.slice(:action))
1414
end
1515

1616
def self.helper_method(*) ; end

0 commit comments

Comments
 (0)