Skip to content

Commit

Permalink
Update the README
Browse files Browse the repository at this point in the history
  • Loading branch information
elnurvl committed May 20, 2024
1 parent 4c4f390 commit 66a6dcb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,36 @@ public test_a_protected_route()
->assertOk();
}
```
`$user` argument receives a string identifier or
an Eloquent model, identifier of which is expected to be the property referred in **user_provider_credential** config.
Whatever you pass in the payload will override default claims,
which includes `aud`, `iat`, `exp`, `iss`, `azp`, `resource_access` and either `sub` or `preferred_username`,
depending on **token_principal_attribute** config.

Alternatively, payload can be provided in a class property, so it can be reused across multiple tests:

```php
use KeycloakGuard\ActingAsKeycloakUser;

protected $tokenPayload = [
'aud' => 'account',
'exp' => 1715926026,
'iss' => 'https://localhost:8443/realms/master'
];

public test_a_protected_route()
{
$payload = [
'exp' => 1715914352
];
$this->actingAsKeycloakUser($user, $payload)
->getJson('/api/somewhere')
->assertOk();
}
```

Priority is given to the claims in passed as an argument, so they will override ones in the class property.
`$user` argument has the highest priority over the claim referred in **token_principal_attribute** config.

# Contribute

Expand Down

0 comments on commit 66a6dcb

Please sign in to comment.