Securing REST API using custom tokens (stateless, no UI, no cookies, no basic authentication, no OAuth, no login page)

My sample app does exactly this – securing REST endpoints using Spring Security in a stateless scenario. Individual REST calls are authenticated using an HTTP header. Authentication information is stored on the server side in an in-memory cache and provides the same semantics as those offered by the HTTP session in a typical web application. … Read more

Restful web service authentication

One way I’ve seen this done in APIs (and the way am currently implementing it) is to create a RESTful resource called Session which is created via a POST which supplies a username and password. Here is basically how I’ve implemented it: POST /sessions { Username: “User”, Password: “Password” } Create an time limited session … Read more

How to use jti claim in a JWT

Indeed, storing all issued JWT IDs undermines the stateless nature of using JWTs. However, the purpose of JWT IDs is to be able to revoke previously-issued JWTs. This can most easily be achieved by blacklisting instead of whitelisting. If you’ve included the “exp” claim (you should), then you can eventually clean up blacklisted JWTs as … Read more

What status code should I use when session token is invalid?

401 Unauthorized. Your existing session token doesn’t authorize you any more, so you are unauthorized. Don’t forget that a session token is just a short-cut to avoid having to provide credentials for every request. Sending 404 is incorrect because, as you observe, the resource does exist. You just don’t currently have authorization to see it. … Read more

AngularJS Authentication + RESTful API

This is taken from my blog post on url route authorisation and element security here but I will briefly summaries the main points 🙂 Security in frontend web application is merely a starting measure to stop Joe Public, however any user with some web knowledge can circumvent it so you should always have security server-side … Read more

How do I implement login in a RESTful web service?

As S.Lott pointed out already, we have a two folded things here: Login and authentication Authentication is out-of-scope here, as this is widely discussed and there is common agreement. However, what do we actually need for a client successfully authenticate itself against a RESTful web service? Right, some kind of token, let’s call it access-token. … Read more

What is the difference between JSON Web Signature (JWS) and JSON Web Token (JWT)?

JWT actually uses JWS for its signature. From the specification’s abstract: JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JavaScript Object Notation (JSON) object that is used as the payload of a JSON Web Signature (JWS) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)