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

Refresh is being guarded by a token check, returns "invalid. #39

Open
raf202 opened this issue Jul 26, 2017 · 2 comments
Open

Refresh is being guarded by a token check, returns "invalid. #39

raf202 opened this issue Jul 26, 2017 · 2 comments

Comments

@raf202
Copy link

raf202 commented Jul 26, 2017

Trying to Refresh a token returns "Invalid token":
Fixed when I remove the refresh rout from the api.auth middleware group:


 $api->group([
        'middleware' => 'api.auth',
    ], function ($api) {
        $api->get('/', [
            'uses' => 'App\Http\Controllers\APIController@getIndex',
            'as' => 'api.index'
        ]);
        $api->get('/auth/user', [
            'uses' => 'App\Http\Controllers\Auth\AuthController@getUser',
            'as' => 'api.auth.user'
        ]);
        $api->patch('/auth/refresh', [
            'uses' => 'App\Http\Controllers\Auth\AuthController@patchRefresh',
            'as' => 'api.auth.refresh'
        ]); // REMOVED THIS FROM THE GROUP AND LEFT IT UNPROTECTED, OR ELSE TOKEN WOULD NOT BE REFRESHED
        $api->delete('/auth/invalidate', [
            'uses' => 'App\Http\Controllers\Auth\AuthController@deleteInvalidate',
            'as' => 'api.auth.invalidate'
        ]);
    });
@pmventura
Copy link

I had the same issue on #33

@raf202
Copy link
Author

raf202 commented Jul 26, 2017

Also, you have to make 3 calls to refresh an expired token:

  1. The call you actually want to make, which is denied and returns that the token has expired
  2. The token refreshing call -> returns the token so you can save client side
  3. The call you actually want to make, again (now with the refreshed token)

I don't know if theres a specific reason for it, but it seems a bit like bad design for me. Perhaps a better workflow with one round trip to the server would be:

  1. The call you actually want to make -> Server side checks that the token has expired, checks for the refresh window -> if it's in the refresh window, make the call and return 'token expired' with a new token. You check and save the token client side.

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

No branches or pull requests

2 participants