Skip to main content

Posts

Showing posts with the label Security

REST tutorial : security with JWT token

Greetings! This is the last part of our security tutorial. Complete source code $ git clone https://github.com/slmanju/todoapp.git $ cd todoapp $ git checkout security follow the complete tutorial JWT JSON Web Token is an open standard that defines a compact and self-contained way for securely sharing data between parties using a JSON object. Compact - smaller size Self-contained - payload contains all the required information Typically contains, Header - consists of the type of the token, hashing algorithm being used Payload - contains the claims. Signature A token fields are separated by dots like this, xxx.yyy.zzz https://jwt.io/introduction/ Since we already have added token support in our previes tutorial, we only have to modify it to a JWT token. Sample Header {   "alg": "HS512" } Sample Payload {   "sub": "manjula",   "userId": "1",   "role": "ADMIN",   ...

REST tutorial : security

Greetings! So far we have created a nice looking REST API with Java tech stack. But it is missing a crucial piece. Security!!! Complete source code,  todoapp $ git clone https://github.com/slmanju/todoapp.git $ cd todoapp $ git checkout security Spring Security Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications. spring-security Lets add spring security starter to our project. compile('org.springframework.boot:spring-boot-starter-security') $ gradle clean bootrun $ curl -i http://localhost:8080/todos You will get a message like this, {"timestamp":1515304279482,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/todos"} With just adding the library Spring has secured our application! Have a look at the con...