Skip to content

Commit

Permalink
Criada a configuração validate_token_when_call_has_role
Browse files Browse the repository at this point in the history
  • Loading branch information
g-portugues committed Jun 25, 2019
1 parent 3f9aa40 commit 788406f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
keycloak (2.4.1)
keycloak (2.5.0)
json
jwt
rest-client
Expand All @@ -14,11 +14,11 @@ GEM
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (2.1.0)
jwt (2.1.0)
json (2.2.0)
jwt (2.2.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mime-types-data (3.2019.0331)
netrc (0.11.0)
rake (10.5.0)
rest-client (2.0.2)
Expand All @@ -40,7 +40,7 @@ GEM
rspec-support (3.7.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unf_ext (0.0.7.6)

PLATFORMS
ruby
Expand Down
5 changes: 3 additions & 2 deletions lib/keycloak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Keycloak
class << self
attr_accessor :proxy, :generate_request_exception, :keycloak_controller,
:proc_cookie_token, :proc_external_attributes,
:realm, :auth_server_url
:realm, :auth_server_url, :validate_token_when_call_has_role
end

def self.explode_exception
Expand Down Expand Up @@ -253,7 +253,7 @@ def self.has_role?(user_role, access_token = '', client_id = '', secret = '', to
secret = @secret if secret.blank?
token_introspection_endpoint = @configuration['token_introspection_endpoint'] if token_introspection_endpoint.blank?

if user_signed_in?(access_token, client_id, secret, token_introspection_endpoint)
if !Keycloak.validate_token_when_call_has_role || user_signed_in?(access_token, client_id, secret, token_introspection_endpoint)
dt = decoded_access_token(access_token)[0]
dt = dt["resource_access"][client_id]
if dt != nil
Expand Down Expand Up @@ -351,6 +351,7 @@ def self.verify_setup
def self.setup_module
Keycloak.proxy ||= ''
Keycloak.keycloak_controller ||= KEYCLOACK_CONTROLLER_DEFAULT
Keycloak.validate_token_when_call_has_role ||= false
get_installation
end

Expand Down
2 changes: 1 addition & 1 deletion lib/keycloak/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Keycloak
VERSION = "2.4.1"
VERSION = "2.5.0"
end

0 comments on commit 788406f

Please sign in to comment.