Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to throw exceptions for handling later and to disable the catch-all entry point #10

Merged
merged 2 commits into from
May 16, 2014

Conversation

gfreeau
Copy link
Contributor

@gfreeau gfreeau commented May 15, 2014

Hello,

This pull request does not change any behaviours by default, but it does allow you to have the listener throw exceptions instead of handling the response.

This is useful when using FOSRestBundle which has a much more comprehensive exception controller. It handles setting the correct exception code and in the dev environment shows things such as stack traces. More info is here: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md and here an example of the listener: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/EventListener/AccessDeniedListener.php

For the same reason, the entry point is not required as this bundle can handle setting the correct response code and message.

The simple config for activating these changes it is:

        api:
            pattern:   ^/api
            stateless: true
            lexik_jwt:
                throw_exceptions: true
                create_entry_point: false

@slashfan
Copy link
Contributor

Very nice ! Could you update the README ?

@gfreeau
Copy link
Contributor Author

gfreeau commented May 16, 2014

I updated the README.

@slashfan
Copy link
Contributor

Great, thanks.

slashfan pushed a commit that referenced this pull request May 16, 2014
Added ability to throw exceptions for handling later and to disable the catch-all entry point
@slashfan slashfan merged commit 27fdd41 into lexik:master May 16, 2014
chalasr added a commit that referenced this pull request Dec 14, 2023
…figuration (Julius Böllmann)

This PR was merged into the 2.x branch.

Discussion
----------

Wrong type exception for AccessTokenLoader with certain configuration

If I use the feature "webtoken" with that bundle than the following configuration (only signing jwk but not encrypting), leads to an exception when the Encoder is loader and Dependencies are injected.

```
lexik_jwt_authentication:
    public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
    encoder:
        service: lexik_jwt_authentication.encoder.web_token
    access_token_issuance:
        enabled: true
        signature:
            algorithm: EdDSA
            key: '%env(SIGNATURE_KEY)%'
    access_token_verification:
        enabled: true
        signature:
            allowed_algorithms:
                - EdDSA
            keyset: '%env(SIGNATURE_VERIFICATION_KEYSET)%'
```
The problem in my opinion is the default xml Service configuration, that does not specify the right type. If one acitvates encryption this error disappears as than this config is overwritten anyhow.

```
In AccessTokenLoader.php line 38:
Lexik\Bundle\JWTAuthenticationBundle\Services\WebToken\AccessTokenLoader::__construct(): Argument #10 ($jweHeaderChecker) must be of type ?array, string given, called in /var/www/html/var/cache/test/Container1K8ziZx/getLexikJwtAuthentication_AccessTokenLoaderService.php on line 29
```

Commits
-------

696f600 fix: types for di container for access token loader changed to array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants