Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ecc4676f
Commit
ecc4676f
authored
Sep 18, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak security example
parent
cf4f549b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
README.md
spring-boot-actuator/README.md
+13
-11
No files found.
spring-boot-actuator/README.md
View file @
ecc4676f
...
@@ -285,28 +285,30 @@ Try it out:
...
@@ -285,28 +285,30 @@ Try it out:
$ curl localhost:8080/
$ curl localhost:8080/
{"status": 403, "error": "Forbidden", "message": "Access Denied"}
{"status": 403, "error": "Forbidden", "message": "Access Denied"}
$ curl user:
password
@localhost:8080/
$ curl user:
<password>
@localhost:8080/
{"message": "Hello World"}
{"message": "Hello World"}
The default auto configuration has an in-memory user database with one
The default auto configuration has an in-memory user database with one
entry. If you want to extend or expand that, or point to a database
entry, and the
`<password>`
value has to be read from the logs (at
or directory server, you only need to provide a
`@Bean`
definition for
INFO level) by default. If you want to extend or expand that, or
an
`AuthenticationManager`
, e.g. in your
`SampleController`
:
point to a database or directory server, you only need to provide a
`@Bean`
definition for an
`AuthenticationManager`
, e.g. in your
`SampleController`
:
@Bean
@Bean
public AuthenticationManager authenticationManager() throws Exception {
public AuthenticationManager authenticationManager() throws Exception {
return new AuthenticationManagerBuilder(
return new AuthenticationManagerBuilder(
ObjectPostProcessor.QUIESCENT_POSTPROCESSOR).inMemoryAuthentication().withUser("
user
")
ObjectPostProcessor.QUIESCENT_POSTPROCESSOR).inMemoryAuthentication().withUser("
client
")
.password("
password
").roles("USER").and().and().build();
.password("
secret
").roles("USER").and().and().build();
}
}
Try it out:
Try it out:
$ curl client:secret@localhost:8080/
{"status": 403, "error": "Forbidden", "message": "Access Denied"}
$ curl user:password@localhost:8080/
$ curl user:password@localhost:8080/
{"status": 403, "error": "Forbidden", "message": "Access Denied"}
$ curl client:secret@localhost:8080/
{"message": "Hello World"}
{"message": "Hello World"}
## Adding a database
## Adding a database
...
@@ -345,9 +347,9 @@ Then you will be able to inject a `DataSource` into your controller:
...
@@ -345,9 +347,9 @@ Then you will be able to inject a `DataSource` into your controller:
...
...
}
}
The app will run (
going back to the default
security configuration):
The app will run (
with the new
security configuration):
$ curl
user:password
@localhost:8080/
$ curl
client:secret
@localhost:8080/
{"error":"Internal Server Error", "status":500, "exception":...}
{"error":"Internal Server Error", "status":500, "exception":...}
but there's no data in the database yet and the
`MESSAGES`
table
but there's no data in the database yet and the
`MESSAGES`
table
...
@@ -362,7 +364,7 @@ Then you will be able to inject a `DataSource` into your controller:
...
@@ -362,7 +364,7 @@ Then you will be able to inject a `DataSource` into your controller:
Now when you run the app you get a sensible response:
Now when you run the app you get a sensible response:
$ curl
user:password
@localhost:8080/
$ curl
client:secret
@localhost:8080/
{"ID":0, "MESSAGE":"Hello Phil"}
{"ID":0, "MESSAGE":"Hello Phil"}
Obviously, this is only the start, but hopefully you have a good grasp
Obviously, this is only the start, but hopefully you have a good grasp
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment