You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changed this SpringBoot Application into a Maven Library, which can be included via Gradle or Maven in your SpringBoot Application.
Removed front end html, javascript, css, etc..
Updated all libraries.
Setup Maven Central build steps.
Created a CHANGELOG and automatic CHANGELOG generation.
Bumped version to 3.0.0.
And much much more!
Copy file name to clipboardExpand all lines: CONFIG.md
-9Lines changed: 0 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,6 @@ Welcome to the User Framework SpringBoot Configuration Guide! This document outl
23
23
-**DDL Auto (`spring.jpa.hibernate.ddl-auto`)**: Hibernate schema generation strategy, defaults to `update`.
24
24
-**Dialect (`spring.jpa.properties.hibernate.dialect`)**: Set this to the appropriate dialect for your database, defaults to `org.hibernate.dialect.MariaDBDialect`.
25
25
26
-
### Application Properties
27
-
28
-
-**Name (`spring.application.name`)**: Set your application's name, defaults to `User Framework`.
29
26
30
27
## User Settings
31
28
@@ -47,18 +44,12 @@ Welcome to the User Framework SpringBoot Configuration Guide! This document outl
47
44
48
45
-**From Address (`spring.mail.fromAddress`)**: The email address used as the sender in outgoing emails.
49
46
50
-
## Copyright
51
-
52
-
-**First Year (`spring.copyrightFirstYear`)**: The starting year for the copyright notice.
53
47
54
48
## Role and Privileges
55
49
56
50
-**Roles and Privileges (`spring.roles-and-privileges`)**: Map out roles to their respective privileges.
57
51
-**Role Hierarchy (`spring.role-hierarchy`)**: Define the hierarchy and inheritance of roles.
58
52
59
-
## New Relic Monitoring
60
-
61
-
-**API Key and Account ID (`management.newrelic.metrics.export`)**: Required if you're integrating with New Relic for monitoring.
-[Refer to the Demo Project](#refer-to-the-demo-project)
7
+
-[Configuring Your Local Environment](#configuring-your-local-environment)
8
+
-[Database](#database)
9
+
-[Mail Sending (SMTP)](#mail-sending-smtp)
10
+
-[SSO OAuth2 with Google and Facebook](#sso-oauth2-with-google-and-facebook)
11
+
-[Overriding Spring Security Messages](#overriding-spring-security-messages)
12
+
-[Notes](#notes)
13
+
14
+
1
15
# SpringUserFramework
2
16
3
-
SpringUserFramework is a Java Spring Boot User Management Framework designed to simplify the implementation of user management features in your Spring-based web application. It is built on top of [Spring Security](https://spring.io/projects/spring-security) and provides out-of-the-box support for registration, login, logout, and forgot password flows. The framework includes basic example pages that are unstyled, allowing for seamless integration into your application.
17
+
SpringUserFramework is a Java Spring Boot User Management Framework designed to simplify the implementation of user management features in your SpringBoot web application. It is built on top of [Spring Security](https://spring.io/projects/spring-security) and provides out-of-the-box support for registration, login, logout, and forgot password flows. It also supports SSO with Google and Facebook.
18
+
19
+
The framework includes basic example pages that are unstyled, allowing for seamless integration into your application.
4
20
5
21
## Summary
6
22
@@ -21,6 +37,8 @@ The framework provides support for the following features:
21
37
- Login and logout functionality.
22
38
- Forgot password flow.
23
39
- Database-backed user store using Spring JPA.
40
+
- SSO support for Google
41
+
- SSO support for Facebook
24
42
- Configuration options to control anonymous access, whitelist URIs, and protect specific URIs requiring a logged-in user session.
25
43
- CSRF protection enabled by default, with example jQuery AJAX calls passing the CSRF token from the Thymeleaf page context.
26
44
- Audit event framework for recording and logging security events, customizable to store audit events in a database or publish them via a REST API.
@@ -31,85 +49,87 @@ The framework provides support for the following features:
31
49
32
50
## How To Get Started
33
51
34
-
### Quickstart Guide
35
-
You can jump right in and get started by following the [Quickstart Guide](QUICKSTART.md).
36
-
37
-
For more information, read on.
38
-
39
-
### Configuring Your Local Environment
40
-
There is an example configuration file in /src/main/resources called application-local.yml-example. By default this project's gradle bootRun command runs Spring using the "local" profile. So you can just copy that file to application-local.yml and replace the values (keys, URLs, etc..) with your values. If you are using a different profile to run (such as default) you will just need to ensure the same configs are in place in your active configuration file(s).
41
-
42
-
You can read more about the required configuration values in the [Configuration Guide](CONFIG.md).
43
-
44
-
Missing or incorrect configuration values will make this framework not work correctly.
52
+
This Framework is now available as a library on Maven Central. You can add it to your Gradle project by adding the following dependency to your `build.gradle` file:
45
53
46
-
### Database
47
-
This framework uses a database as a user store. By buildling on top of Spring JPA it is easy to use which ever datastore you like. The example configuration in application.yml is for a [MariaDB](https://mariadb.com) 10.5 database. You will need to create a user and a database and configure the database name, username, and password.
Please check for the latest version on [Maven Central](https://central.sonatype.com/artifact/com.digitalsanctuary/ds-spring-user-framework) (this README may not always be up to date).
69
+
When upgrading to a new version, please check the [CHANGELOG](CHANGELOG.md) for any breaking changes or new features.
The framework sends emails for verficiation links, forgot password flow, etc... so you need to configure the outbound SMTP server and authentication information.
72
+
### Refer to the Demo Project
73
+
I have created a demo project that uses this framework. You can find it here: [SpringUserFrameworkDemo](https://github.com/devondragon/SpringUserFrameworkDemoApp). This demo project is a full SpringBoot application that uses this framework as a library. You can use it as a reference for how to use this framework in your own project. It demonstrates all of the configuration values and how to override them in your own `application.yml` file. It also has functioning examples for all front end pages, javascript, etc...
63
74
64
-
### SSO OAuth2 with Google and Facebook
65
-
The framework supports SSO OAuth2 with Google and Facebook. To enable this you need to configure the client id and secret for each provider.
75
+
In addition to being a fully functional reference, you can also use the demo project as a starting point for your own project. Just clone the repo and start building your own application on top of it.
66
76
67
-
For public OAuth you will need a public hostname and HTTPS enabled. You can use ngrok to create a public hostname and tunnel to your local machine. You can then use the ngrok hostname in your Google and Facebook developer console configuration.
68
77
78
+
### Configuring Your Local Environment
69
79
70
-
### New Relic
71
-
Out of the box the project includes the New Relic Telemetry module, and as such requires a New Relic account id, and associated API key. If you don't use New Relic you can remove the dependancy from the build.gradle file and ignore the configuration values.
80
+
You can read more about the required configuration values in the [Configuration Guide](CONFIG.md).
72
81
73
-
Beyond that the default configurations should be all you need, although of course you can customize things however you like.
82
+
Missing or incorrect configuration values will make this framework not work correctly.
74
83
75
-
## Docker
84
+
### Database
85
+
This framework uses a database as a user store. By building on top of Spring JPA it is easy to use whichever database you like.
76
86
77
-
After running gradle build, you can build a simple Docker image of the application using the provided Dockerfile. Please note that this Dockerfile is basic and does not incorporate advanced features such as layering or buildpacks that you may require for production applications.
87
+
If you set your JPA Hibernate ddl-auto property to "create" it will create the tables for you. If you set it to "update" it will update the tables for you. If you set it to "none" you will need to create the tables yourself.
78
88
79
-
Additionally, a docker-compose file is included, which launches a stack with the Spring Boot Application, MariaDB Database, and Postfix Mail Server. The configurations in the docker-compose file are set to make everything work smoothly. However, please be aware that sending emails from your computer (via the docker Postfix Mail Server) may be blocked by email providers due to spam checks. You can use temporary email addresses from [10MinuteMail.com](https://10minutemail.com) for testing purposes, but for real use, it is recommended to configure the Spring Boot application to use a real mail server for outbound transactional emails.
89
+
If you are not using automatic schema updates or Flyway, you can set up your database manually using the provided `schema.sql` file:
80
90
91
+
```bash
92
+
mysql -u username -p database_name < src/main/resources/schema.sql
93
+
```
81
94
95
+
Flyway support will be coming soon. This will allow you to automatically update your database schema as you deploy new versions of your application.
82
96
83
-
## Overriding Spring Security Messages
84
97
85
-
You may want to override the default Spring Security user facing messages. You can do this in your messages.properties file, by adding any of the message keys from Spring Security (found here: [Spring Security Messages](https://github.com/spring-projects/spring-security/blob/main/core/src/main/resources/org/springframework/security/messages.properties)) and providing your own values.
98
+
### Mail Sending (SMTP)
99
+
The framework sends emails for verification links, forgot password flow, etc... so you need to configure the outbound SMTP server and authentication information. This is done in the `application.yml` file. You can see the example configuration in the Demo Project's `application.yml` file. Please also refer to the [Spring Boot Mail Properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#mail-properties) for more information on the available properties.
86
100
87
101
88
-
## Dev Tools
102
+
### SSO OAuth2 with Google and Facebook
103
+
The framework supports SSO OAuth2 with Google and Facebook. To enable this you need to configure the client id and secret for each provider. This is done in the application.yml (or application.properties) file using the [Spring Security OAuth2 properties](https://docs.spring.io/spring-security/reference/servlet/oauth2/login/core.html). You can see the example configuration in the Demo Project's `application.yml` file.
For public OAuth you will need a public hostname and HTTPS enabled. You can use ngrok or Cloudflare tunnels to create a public hostname and tunnel to your local machine during development. You can then use the ngrok hostname in your Google and Facebook developer console configuration.
94
124
95
-
### Live Reload over HTTPS Setup
96
-
If you are running your local dev env using HTTPS or referencing it from a ngrok tunnel using HTTPS, you will need to make a few changes to get Live Reload to work. First you need to tell the application to use HTTPS by setting the following properties in your application.yml file:
97
125
98
-
```
99
-
spring.devtools.livereload.https=true
100
-
```
101
126
102
-
You then need to install mitmproxy and configure it to intercept the HTTPS traffic. You can do this by running the following command:
You may want to override the default Spring Security user facing messages. You can do this in your messages.properties file, by adding any of the message keys from Spring Security (found here: [Spring Security Messages](https://github.com/spring-projects/spring-security/blob/main/core/src/main/resources/org/springframework/security/messages.properties)) and providing your own values.
107
131
108
-
By default, mitmproxy uses self-signed SSL certificates, so you need to tell your browser to trust them before this will work. You can do this by opening https://localhost:35739/livereload.js in your browser and going through the steps to trust the server and certificate.
109
132
110
-
Alternatively, you can configure mitmproxy to use real certificates and avoid this step. Follow these directions: https://docs.mitmproxy.org/stable/concepts-certificates/
111
133
112
134
## Notes
113
-
Much of this is based on the [Baeldung course on Spring Security](https://www.baeldung.com/learn-spring-security-course). If you want to learn more about Spring Security or would like to add SSO integration or 2FA to your application, that guide is a great place to start.
114
-
115
135
Please note that there is no warranty or guarantee of functionality, quality, performance, or security made by the author. The code is available freely, but you assume all responsibility and liability for its usage in your application.
0 commit comments