Bauette
Bauette

Reputation: 37

Spring RESTful web service auth

I am learning Spring and have written a simple RESTful web service that is not intended for browsers but for native mobile apps only. When trying to implement basic authentication for users. I've hit a wall, because the sources (even official tutorials) assume (and recommend) using OAuth2 through a browser with SSO and\or social logins.

All I want is to create an API RESTful endpoint that will take an email address and a password and return a token (possibly JWT). I do not need extended support for roles (but am not against it) and dynamic token revokation if that matters.

Is there any easy library/solution/tutorial that focuses on something similar?

Edit: Thanks for the answers — all of them shed more light on the auth process and are quite useful and on point!

Upvotes: 0

Views: 68

Answers (2)

saurabh kedia
saurabh kedia

Reputation: 331

Please check here, I have a working example for the spring security on my github. You may need to change the spring.active.profiles=jwt, to enable the jwt configurations on this project.

Upvotes: 1

Sridhar Patnaik
Sridhar Patnaik

Reputation: 1118

There are many tutorials available on internet for implementing JWT token based authentication using Spring Boot. Please find below some of them

https://dzone.com/articles/spring-boot-security-json-web-tokenjwt-hello-world https://www.javainuse.com/spring/boot-jwt

Please go through them and try to implement. If you need a working code for reference, you can search GitHub for code. This is one of them https://github.com/murraco/spring-boot-jwt

Upvotes: 1

Related Questions