Class: StandardId::Oauth::RefreshTokenFlow

Inherits:
TokenGrantFlow show all
Defined in:
lib/standard_id/oauth/refresh_token_flow.rb

Instance Attribute Summary

Attributes inherited from TokenGrantFlow

#params, #request

Attributes inherited from BaseRequestFlow

#current_account, #params, #request

Instance Method Summary collapse

Methods inherited from TokenGrantFlow

#execute, extra_permitted_keys, #initialize

Methods inherited from BaseRequestFlow

expect_params, expected_params, extra_permitted_keys, #initialize, permit_params, permitted_params

Constructor Details

This class inherits a constructor from StandardId::Oauth::TokenGrantFlow

Instance Method Details

#authenticate!Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/standard_id/oauth/refresh_token_flow.rb', line 7

def authenticate!
  validate_client_secret!(params[:client_id], params[:client_secret]) if params[:client_secret].present?

  @refresh_payload = StandardId::JwtService.decode(params[:refresh_token])
  raise StandardId::InvalidGrantError, "Invalid or expired refresh_token" if @refresh_payload.blank?

  if @refresh_payload[:client_id] != params[:client_id]
    raise StandardId::InvalidGrantError, "Refresh token was not issued to this client"
  end

  validate_scope_narrowing!
end