Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

rmitula/spring-boot-basic-authentication

Repository files navigation

spring-boot-basic-authentication

Simple Spring-Security basic authentication using method level security

Usage

Public access

Test the public endpoint without any authentication:

curl http://localhost:8080/public

Response:

Hello Public!

Private access

Test the private endpoint without authentication:

curl http://localhost:8080/private

You receive the following response, which indicates you are not authorized to access the resource:

HTTP Status 401 - Full authentication is required to access this resource

Test the private endpoint with ROLE_USER account authentication:

curl -u user:password http://localhost:8080/private

Response:

Hello Private!

Test the private endpoint with ROLE_ADMIN account authentication:

curl -u admin:password http://localhost:8080/private

Response:

Hello Private!

Test the private endpoint with wrong user authentication:

curl -u user:wrongpassword http://localhost:8080/private

You receive the following response, which indicates you are not authorized to access the resource:

HTTP Status 401 - Bad credentials

Admin access

Test the admin endpoint with ROLE_USER account authentication:

curl -u user:password http://localhost:8080/admin

Response:

{ 
 "timestamp":1515542457567,
 "status":403,
 "error":"Forbidden",
 "exception":"org.springframework.security.access.AccessDeniedException",
 "message":"Dostęp zabroniony",
 "path":"/admin"
}

Test the admin endpoint with ROLE_ADMIN account authentication:

curl -u admin:password http://localhost:8080/admin

Response:

Hello Admin!

About

Simple Spring Security Basic Authentication App

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /