Configuration: Service Module - ChrisMavrommatis/Binacle.Net GitHub Wiki
The Service Module equips Binacle.Net for use in public environments by introducing essential features like rate limiting, user management, and authentication. Authenticated users can bypass the rate limiter to ensure seamless access to calculation endpoints.
While Binacle.Net is ideally hosted in a private cloud, the Service Module is designed for those who need a public deployment. Key choices, such as database type, were tailored for Binacle.Netβs needs and cost-effectiveness. However, this module ensures that public hosting remains efficient and prevents excessive, costly requests.
How It Works
The Service Module requires a database for user storage and includes a user management API, with an admin user created by default. Only admins can manage users.
It also provides an authentication endpoint, where users can log in and receive a token. This token is used to bypass the rate limiter for calculation endpoints, allowing priority access for authenticated users.
API Endpoints
Once enabled, the following API endpoints become available:
Authentication:
POST /api/auth/token
: Authenticates a user by email and password, returning a JWT token. This token is used in theAuthorization
header as aBearer
token for subsequent requests.
User Management:
POST /api/users
: Create a new user.PUT /api/users/{email}
: Update user details.PATCH /api/users/{email}
: Change a user's password.DELETE /api/users/{email}
: Delete a user.
Only admin users can manage other users. Admins can create, modify, activate/deactivate accounts, and promote or demote users. Only active users can interact with the API. Deleting a user is a soft deleteβusers remain in the database but cannot be restored. A new user with the same email can be created.
Activating the Service Module
To enable the Service Module, set the following environment variable: SERVICE_MODULE=True
, or modify the Features.json
file as shown below:
{
"Features": {
"SERVICE_MODULE": "True",
"SWAGGER_UI": "NotSet",
"UI_MODULE": "NotSet"
}
}
Follow the steps to configure the module. All configuration files are located in /app/Config_Files/ServiceModule
:
app
βββ Config_Files
βββ ServiceModule
βββ ConnectionStrings.json
βββ JwtAuth.json
βββ RateLimiter.json
βββ Users.json
Configuring the Service Module
To complete setup, configure the following: