firebase / php-jwt

PHP package for JWT
BSD 3-Clause "New" or "Revised" License
9.38k stars 1.27k forks source link

CakePHP Views, You are not authorized to access that location #541

Closed russmenum closed 9 months ago

russmenum commented 11 months ago

Everything is working for direct access to endpoints securely with fetch(), but none of the secured can have a CakePHP View.

how do I add the equivalent of

var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "token");

to URL/TABLE/VIEW so they are logged in and cake forms will work when they submit?

I am having trouble finding the documentation.

Basically CAKEPHP side: how do I login, and use the token with <?= $this->Form->create($table) ?>

In my case, the token should already be there in the browser's local storage from the JS pages

localStorage.getItem('userToken')

I just need to load this to a CakeView and use it with the forms somehow so it will authorize. even if like

var myJavascriptVar = JSON.parse( localStorage.getItem('userToken') );

document.cookie = "myJavascriptVar =" + myJavascriptVar;

and PHP side

$myPhpVar= $_COOKIE['myJavascriptVar'];

I am just a little lost how/where I need to pass this to the VIEW Load and FORMs to authorize.

Any help is appreciated. If this is documented somewhere would love to know where. Thank you in advance.

saranshdhingra commented 9 months ago

Hi @russmenum This is not the correct repository to get support for Cake PHP.

If you think everything is working for direct endpoints and not in CAKE, then I recommend posting it in a relevant repo or stackoverflow.

I will be closing this bug for now.

However, if you think there is something that is relevant to this repository, please feel free to reopen this with more information and some reproducible code snippets.

Thanks.