Secure Spring Boot Rest API with Basic Authentication — Part 01

Damith Neranjan Samarakoon
2 min readJun 6, 2020

--

In any API’s major concern is a Security.So, there are several options that you can use secure your REST APIs.

This articles(Part 01 and Part 02), i’m going to walk you through how to secure a spring boot REST API using Basic Authentication.

What is Basic Authentication

Basic Authentication flow

Basic Authentication is a simplest authentication method built in the HTTPProtocol.The Client sends the HTTP Request with the Authorization header.that contain word Basic and base64-encoded string.The string is username:password.for example,

Authorization: Basic ZGFtaXRoOjFxYXoyd3N4QA==

In Rest world, this is one of the simplest method to secure resources.because it does not require cookies. session identifiers or any login pages.

In here, username and password not encrypted or hashed.hence we should not using this authentication method in plain HTTP.But we can use this with HTTPS and it is the recommended way to use this header.

hope you will help this article for get basic idea about basic authentication.In my next article i will implement use case for this.

Thanks & happy coding :-)

--

--

Damith Neranjan Samarakoon

I’m an Engineering Lead @Persistent System, blogger,thinker, husband & father of “little angle”. passionate about Technology,Engineering and Learning.