0

We are creating an online service divided like that: - an API, of course - full JS/AJAX client, no MVC, it is pure JS

We are experienced developers and we do know that we can't secure the JS client code, however, we are trying to figure way to prevent 3rd parties from creating their own client by analyzing our JS API Call and this way restrict access only from our own client.

Thanks in advance!

2
  • 2
    You will not be able to do that. Commented Oct 23, 2012 at 23:01
  • Impossible. One can always observe the http communication. Commented Oct 23, 2012 at 23:03

5 Answers 5

2

We are experienced developers and we do know that we can't secure the JS client code, however, we are trying to figure way to prevent 3rd parties from creating their own client by analyzing our JS API Call and this way only restreint access from our own client.

That is contradiction in terms. If you know that client-side ECMAscript code can never be hidden, it will always be possible for any somewhat experienced developer to analyse your code. Even if heavily obfuscated, minified and uglified.

Use a server-side authentication, by password. Its the only secure way. You just can not prevent that somebody will clone/copy your script.

Sign up to request clarification or add additional context in comments.

1 Comment

Well, i thought we were missing something, somwhere. We can always send 'Cease and Desist' but i tried to avoid this solution. :(
0

I don't think you can. Perhaps generate a key or something to authorize requests.

Comments

0

For you and anyone with a similar question, take heed; it is impossible. If you send a user working code that will communicate with your API, there is nothing you can do to stop then modifying or re-writing that code. The only area you can keep secure is the back-end.

Comments

0

Oh, this is the wrong question to ask.

The question you need to ask is "why do I care if someone accesses my server without my client?"

You obviously have a reason. I can think of one reason only - your server trusts the client to behave nicely. Don't do that. Make sure the server can handle any kind of zany client request. It doesn't have to handle it nicely (throwing a 500 Server Error is OK) - as long as rogue clients can't mess with your data or kill your server entirely.

Comments

0

You could try to obfuscate your javascript code to make it hard readable:

a link to an obfuscator

you can find outhers

If you have authentification, you can pass session id to your API to keep user logged in, so if user is not authentificated he won't be able to get data from your API.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.