https://github.com/cuba-platform/sample-login-restrictions
Customizing the user login procedure
https://github.com/cuba-platform/sample-login-restrictions
cuba-sample
Last synced: over 1 year ago
JSON representation
Customizing the user login procedure
- Host: GitHub
- URL: https://github.com/cuba-platform/sample-login-restrictions
- Owner: cuba-platform
- License: apache-2.0
- Created: 2016-04-01T14:02:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-05T14:59:17.000Z (almost 7 years ago)
- Last Synced: 2025-01-23T08:19:29.248Z (over 1 year ago)
- Topics: cuba-sample
- Language: Java
- Homepage: https://www.cuba-platform.com
- Size: 143 KB
- Stars: 2
- Watchers: 29
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Login Restrictions
This project highlights how developers can customize and manipulate with user login procedure in a CUBA application.
## Objective
Let’s assume that our CUBA application should be licensed as following:
* More than X concurrent users cannot access the system.
* The license has global expiration date when all users will not be able to login.
## Solution
To add custom behaviour for user [login](https://doc.cuba-platform.com/manual-6.10/login.html) we need to create `LoginEventListener` class that will be handle login events in the platform by following the specified steps:
1. In `core` module, under the main project package (in our case `com.company.loginrestrictions`) we create the security subpackage (to keep clear structure and high code readability).
2. Under the `com.company.loginrestrictions.security` package we create `LoginEventListener` class with `@Component` annotation.
3. Create method with `BeforeLoginEvent` input parameter and add `@EventListener` annotation to it. It means this method will be invoked when BeforeLoginEvent is triggered.
4. To access the license properties we use standard [configuration interfaces](https://doc.cuba-platform.com/manual-6.10/config_interfaces.html) mechanism provided by the CUBA Platform. See the `LicenseConfig` interface. It contains the default values of the license parameters.
5. The default license parameters are overridden in the `app.properties` file of the `core` module. See the `license.concurrentSessionsLimit` property.
Based on CUBA Platform 6.10.1
## Issues
Please use https://www.cuba-platform.com/discuss for discussion, support, and reporting problems coressponding to this sample.