A small spring boot application which can manage chess games for demonstration purposes.
A collection of request to interact with the application is in the docs. Use Bruno client to send requests. When application runs with authentication, use the auth request first. All other request will use the auth token form the auth request.
When the application is started with authentication enabled, you first have to authenticate at the keycloak server. Therefore, you obtain a jwt token which is used in all other requests. The configuration of this request can be found withing the bruno file. Change username and password to use other test users. Client id and client secret are defined in the realm.
- test: Profile is used for unit test execution
- dev: Enable authentication but also h2 console is available
- insecure: Disables authentication
To use keycloak you can use the local installation or the docker image which is configured in the docker-compose file.
The realm configuration must be imported via realm.json. Test users are also included in the end of the file. Also, the client secrets are set in the file. Of course this secrets should not be used for production.
The connection from keycloak to the chessmanager app is done with oauth2 like in is this example.
Roles are not used in application now.
| role | description |
|---|---|
| user | |
| manager |
This test user are predefined.
| User name | password | role |
|---|---|---|
| foobar | foobar | manager |
| drdrunkenstein | drdrunkenstein | user |
When application is running with dev profile the database is accessible via browser. Credentials can be taken from spring.datasource in the application.properties
For logging slf4j ist used. The logger can be declared as a static import by the logger factory like this:
private static final Logger LOG = LoggerFactory.getLogger(Foo.class);
To log information there are different methods for every log level. It is possible to use placeholder to write the content of objects into the log.
LOG.debug("Logging the output of my variable: {}.", variable);
For the output medium a logback.xml is configured. There is an appender for console when the app is started in development mode and there is an appender for logging into a file in production mode.
The path to the logback.xml is set in the application.properties like this:
logging.config=classpath:/log/logback.xml
Also, a banner.txt is configured in the application.properties like this:
spring.banner.location=classpath:/log/banner.txt