A simple demo for using spring security, use BCryptPasswordEncoder as PasswordEncoder.
-
Start the project
mvn spring-boot:run
-
Test the '/hello2'
curl -H "Authorization:Basic dXNlcjphZG1pbjEyMzQ1" -X GET localhost:18889/hello2/yumingtao2test result:
Hello, yumingtao2
-
Test the '/hello'
curl -H "Authorization:Basic dXNlcjphZG1pbjEyMzQ1" -d name=yumingtao -X POST localhost:18889/hellotest result:
Hello, yumingtao