Allow logging in with the default OAuth 2 principal

The default principal is "dev@localhost", if you run the system with the development profile (DEV) a user with sys-admin role will be created with that principal as username.
This commit is contained in:
Andreas Svanberg 2024-11-26 13:07:45 +01:00
parent f6acbd805b
commit c3aeb32045
2 changed files with 9 additions and 0 deletions
README.md
core/src/main/java/se/su/dsv/scipro

@ -2,6 +2,11 @@
The web GUI is protected by OAuth 2 log in. Run the Docker Compose containers with
`docker compose up` to start the authorization server to be able to log in.
If you run SciPro in development mode (DEV profile) you will be able to log in
as the "default" OAuth 2 user populated in the upper form. If you have other
data in your database you will have to use the lower form and specify a valid
username in the principal field.
## Working with the API
The API is protected by OAuth 2 acting as a [resource server](https://www.oauth.com/oauth2-servers/the-resource-server/)
verifying tokens using [token introspection](https://datatracker.ietf.org/doc/html/rfc7662).

@ -200,6 +200,10 @@ public class DataInitializer implements Lifecycle {
admin.addRole(Roles.SYSADMIN);
createBeta(admin);
passwordService.updatePassword(admin, "aey7ru8aefei0jaW2wo9eX8EiShi0aan");
Username defaultOAuth2Principal = new Username();
defaultOAuth2Principal.setUsername("dev@localhost");
defaultOAuth2Principal.setUser(admin);
save(defaultOAuth2Principal);
}
private void createBeta(User user) {