Skip to content

Search for 'input_key' in Request Cookies #118

@lauritzh

Description

@lauritzh

Hey there!

We recently had a use case where we wanted to use HttpOnly Cookies to transfer the Keycloak JWT instead of the Authorization header. The modifications to achieve that were rather minimal:

We basically only had to add ?? $this->request->cookies->get($inputKey) to https://github.com/robsontenorio/laravel-keycloak-guard/blob/master/src/KeycloakGuard.php#L61C56-L61C63.

/**
* Get the token for the current request.
*
* @return string
*/
public function getTokenForRequest()
{
  $inputKey = $this->config['input_key'] ?? "";
  return $this->request->bearerToken() ?? $this->request->input($inputKey) ?? $this->request->cookies->get($inputKey);
}

Maybe this is a use case that is also interesting for others?

Best,
Lauritz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions