#Laravel API (Sanctum/Passport)
29 messages · Page 1 of 1 (latest)
They only pass a param for the form_id so that the submitted information is saved to that form, however this would be vulnerable since anyone is able to inspect element, steal their id and spam/abuse it with giberish on their own website
check JWT
- login user
- get token
- send this token with every request to API
- API checks this token and allows/denies the request
https://laravel.com/docs/10.x/sanctum
So the user would need to generate a token on my laravel project, then use this on each request to API
However this brings me back to step 1, anyone is able to copy paste the token when the user uses axios for example through client
Well, that's the point of keeping your API tokens a secret. If you issue an API token for an organization, they're accountable for keeping that secure.
What you can do though is add further "checks", as validate that the incoming request is from a whitelisted IP address etc.
Or that the token is linked to the org they're trying to make changes to, that's authorization
Right that's what I had in mind, however this would ask for some techy knowledge from the organization's side
Well, yes... But the second you say "API key" to an org it's already techy
Exactly, that's why I thought that there was a possible workaround since it's a hard guess what type of framework the org uses
However, I stumbled up on fruitcake/laravel-cors
That package is outdated and built into the framework..
It's included in the framework?
Ahh makes life even easier
In that case i'll just either whitelist ips, or let anyone hit the api
Whitelisting IP's would require contact with the orgs, because you'd need to know what IP addresses they would submit from
And also if their IP changes, it needs to be updated
(Without knowing the actual grand plan of your app)
I take back what I said
We use IP validation in our company, and we have a constant issue with orgs getting new IP addresses
Will probably stick with formspree's idea
I haven't used formspree, but I am pretty sure you have a dashboard there where you also whitelist domains/ip addresses....
Otherwise the issue is like you said, anyone can "steal" your token and just use it
But it doesn't matter that the token is public, if it requires the owner of that token to whitelist
Haven't managed to find that, possibly a premium feature
Yeah I believe it's a forever loop issue, best way to work with it is make it an open api, allow requests from anywhere and have the org manually accept or decline records to be made for example