derrickrozay's avatar

How to secure API endpoints for an app that doesn't have a login?

I'm not sure what to use to secure my API endpoints so not everybody can post or get data without authorization. The app will have no login and registration it will be used in-house. What should I use? JWT? How would I incorporate JWTs without login?

The front end of the app is angular2. There are only two routes. One GET route that pulls data from the database, and one POST route for file upload.

Examples or tutorials would be appreciated.

0 likes
7 replies
derrickrozay's avatar

I'm not sure how I would implement that. Doesnt passport require you to have some sort of user authentication?

gustav1105's avatar

@derrickrozay Yes I think you are right, to consume your api with passport you will have to be auth already to create a fresh api token,

Well just an idea but if the whole operation is just being done in-house, just setup your server to allow certain ip addresses through

J_shelfwood's avatar

Like @gustav1105 said, setup some IP restrictions. I did the same thing for my laravel app. I didn't know how to use passport but I did want to leverage Vue with ajax functionality. I basically just hosted it locally without any API protection at all.

However I don't know if it's the safest thing ever as I'm not an expert when it's about security, though I think you should be fine if the information displayed in the app itself isn't very confidential.

derrickrozay's avatar

@gustav1105 So you mean like on my web hosting only allow certain IPs to access the API? I believe this can also be done in the API itself

gustav1105's avatar

@derrickrozay Yes, I imagine that would be the easies, so you don't have to code in authentication just set it on your server to allow ip's

But I have just read the thread from @bashy he does make a very valid point, I haven't dug this deep into passport so can't really be opinionated but I imagine you could set the bearer token on the request... That will generate the token you need, but as the execution thereof ask @bashy.

Please or to participate in this conversation.