Skip to content

Commit 9fe4bdb

Browse files
authored
Refactor raw_info (#18)
- Move to private api - Move token decoding to a separate method
1 parent 85f839a commit 9fe4bdb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/omniauth/strategies/keycloak.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ def request_phase
8383
}
8484
end
8585

86-
def raw_info
87-
id_token_string = access_token.token
88-
jwks = JSON::JWK::Set.new(@certs)
89-
JSON::JWT.decode id_token_string, jwks
90-
end
91-
9286
protected
9387

9488
def build_access_token
@@ -128,6 +122,15 @@ def log_config(config_json)
128122
log :debug, "Authorize url: #{@authorize_url}"
129123
log :debug, "Token url: #{@token_url}"
130124
end
125+
126+
def raw_info
127+
@raw_info ||= decode_token(access_token.token)
128+
end
129+
130+
def decode_token(token_string)
131+
jwks = JSON::JWK::Set.new(@certs)
132+
JSON::JWT.decode token_string, jwks
133+
end
131134
end
132135
end
133136
end

0 commit comments

Comments
 (0)