-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JohnGrubba/dev
Internal Batch Endpoint
- Loading branch information
Showing
16 changed files
with
208 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
If the provided placeholders are not enough, and you need more logic behind your Templating, you can use our `preprocessing` feature. | ||
This feature allows you to run a custom function on the E-Mail Template before it is sent out. This function will be able to add / modify / remove placeholders from the template. You can also use this function to add custom logic to the template.<br> | ||
Examples of what you can do with this feature: | ||
|
||
!!! Info "Usage Examples of Preprocessing E-Mail Templates" | ||
- Adding a Formatted Date to the E-Mail Template | ||
- Utilizing an external Service to generate a QR Code | ||
- Adding a Random Quote to the E-Mail Template | ||
- Sending a Request to an external API | ||
|
||
### Example | ||
In this example, we will add a `timestamp` placeholder to the E-Mail Template. This placeholder will contain the current date and time when the E-Mail is sent out. | ||
|
||
!!! Note "Preprocessing Function" | ||
- The function should be defined in a Python file in the `config/email` folder. The function should be named `preprocess` and should accept a single parameter `kwargs` which is a dictionary containing all the placeholders available in the E-Mail Template. | ||
- The function should return the modified `kwargs` object. | ||
- The Filename should be the same as the E-Mail Template filename with the `.py` extension. (e.g. `WelcomeMail.py` for the `WelcomeMail.html` template) | ||
|
||
In this example, we will add a `timestamp` placeholder to the `ConfirmEmail.html` template. | ||
```python hl_lines="4" linenums="1" title="config/email/ConfirmEmail.py" | ||
from datetime import datetime | ||
|
||
def preprocess(kwargs: dict) -> dict: | ||
kwargs["timestamp"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||
return kwargs | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
If you want to further customize the service you can take a look at the `docker-compose.yml` file in the root directory of the repository. This file contains all the configuration options for the service. You can change the port on which the service is running, the volume mounts, and the environment variables. | ||
|
||
#### API Configuration | ||
The Prefix for all Parameters here is `services.api`. | ||
The Following Environment Variables can be set in the `docker-compose.yml` file to configure the API: | ||
|
||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `ports` | **Datatype:** String <br> **Default:** `"3250:80"` <br> Only change the left (host) side of the ports. The API will always run on Port 80 internally, and can be forwarded to any port on the host system. In this example `3250`. | | ||
| `volumes` | **Datatype:** String <br> **Default:** `"./config:/app/config"` <br> The volume mount for the configuration file. Only change the left (host) side of the configuration folder directory. In this example `./config`. | | ||
|
||
#### Database Configuration | ||
The Prefix for all Parameters here is `services.db.environment`. | ||
When changing the database configuration, make sure to also change the `api` section in the `docker-compose.yml` file to reflect the new database connection. | ||
The following environment variables can be set in the `docker-compose.yml` file to configure the database connection: | ||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `MONGO_INITDB_ROOT_USERNAME` | **Datatype:** String <br> **Default:** `"admin"` <br> The Root Username for the Database. | | ||
| `MONGO_INITDB_ROOT_PASSWORD` | **Datatype:** String <br> **Default:** `"admin"` <br> The Root Password for the Database. | | ||
| `MONGO_INITDB_DATABASE` | **Datatype:** String <br> **Default:** `"ezauth"` <br> The Database Name. | | ||
|
||
You can also change the location of the database data by changing the `volumes` section of the `db` section in the `docker-compose.yml` file. |
120 changes: 62 additions & 58 deletions
120
docs/getting-started/configuration.md → docs/configuration/configuration.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,62 @@ | ||
# Configuration | ||
|
||
To configure EZAuth you can take a look at the `configtemplate.json` file in the `config` directory. This file contains all the configuration options for EZAuth. | ||
|
||
## Parameters table | ||
|
||
All configuration parameters are listed in the tables below. | ||
Make sure that all parameters are set correctly before starting the service. | ||
|
||
!!! Warning "Apply Configuration" | ||
If you change the configuration file, make sure to restart the service to apply the changes. | ||
|
||
### Signup Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `signup.enable_conf_email` | **Datatype:** Boolean <br> **Default:** `false` <br> Enable or disable the confirmation E-Mail for new users. | | ||
| `signup.conf_code_expiry` | **Datatype:** Integer <br> **Default:** `5` <br> The time in minutes until the confirmation code expires. | | ||
| `signup.conf_code_complexity` | **Datatype:** Integer <br> **Default:** `1` <br> The complexity of the confirmation code. <br> **Possible Values** <br> <ul><li>**1**: `4 Digit Numeric`</li><li>**2**: `6 Digit Numeric`</li><li>**3**: `4 Characters`</li><li>**4**: `6 Characters`</li></ul> | | ||
| `signup.enable_welcome_email` | **Datatype:** Boolean <br> **Default:** `false` <br> Enable or disable the welcome E-Mail for new users. | | ||
|
||
|
||
### E-Mail Configuration | ||
|
||
!!! Warning "SMTP SSL required" | ||
EZAuth uses SMTP_SSL to send E-Mails. Make sure that your SMTP server supports SSL. | ||
Currently EZAuth does not support STARTTLS. | ||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `email.login_usr` | **Datatype:** String <br> **Default:** `""` <br> E-Mail Login Identifier (mostly the E-Mail itself). <br> **Example:** [email protected] | | ||
| `email.login_pwd` | **Datatype:** String <br> **Default:** `""` <br> E-Mail Login Password. | | ||
| `email.sender_email` | **Datatype:** String <br> **Default:** `""` <br> E-Mail address from which the E-Mails are sent (mostly the same as `email.login_usr`) | | ||
| `email.smtp_host` | **Datatype:** String <br> **Default:** `""` <br> SMTP Host for the E-Mail server. <br> **Example:** `smtp.gmail.com` | | ||
| `email.smtp_port` | **Datatype:** Integer <br> **Default:** `465` <br> SMTP Port for the E-Mail server. | | ||
|
||
### Session Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `session.session_expiry_seconds` | **Datatype:** Integer <br> **Default:** `86400` <br> The time in seconds until a login session expires. Expires on Client (Browser) and on the Server (Database). | | ||
| `session.max_session_count` | **Datatype:** Integer <br> **Default:** `5` <br> Maximum amount of sessions for one User. | | ||
| `session.auto_cookie` | **Datatype:** Boolean <br> **Default:** `true` <br> Specifies if the API should automatically return a `Set-Cookie` header to potentially automatically set the Session Token for the client. May simplify upcoming requests to this API. | | ||
| `session.auto_cookie_name` | **Datatype:** String <br> **Default:** `session` <br> The name of the cookie which will be set by the API. | | ||
|
||
### Internal API Configuration | ||
|
||
!!! danger "Internal API Key" | ||
Change this **immediately** after cloning the repository. Keeping the default value is a **severe security risk**. | ||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `internal.internal_api_key` | **Datatype:** String <br> **Default:** `CHANGE_ME_NOW` <br> This is **sensitive** information and must **never** be exposed anywhere. | | ||
| `internal.internal_columns` | **Datatype:** List <br> **Default:** `["_id"]` <br> Columns that should only be revealed via the internal API. This example will never reveal `_id` to public endpoints, but just to the `/internal` endpoints as well as E-Mails. | | ||
|
||
### Account Features Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `account_features.enable_change_password` | **Datatype:** Boolean <br> **Default:** `true` <br> Enable or disable the password reset feature. | | ||
| `account_features.change_password_confirm_email` | **Datatype:** Boolean <br> **Default:** `true` <br> Enable or disable the password change confirmation E-Mail. | | ||
# Configuration | ||
|
||
To configure EZAuth you can take a look at the `configtemplate.json` file in the `config` directory. This file contains all the configuration options for EZAuth. | ||
|
||
## Parameters table | ||
|
||
All configuration parameters are listed in the tables below. | ||
Make sure that all parameters are set correctly before starting the service. | ||
|
||
!!! Warning "Apply Configuration" | ||
If you change the configuration file, make sure to restart the service to apply the changes. | ||
|
||
### Signup Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `signup.enable_conf_email` | **Datatype:** Boolean <br> **Default:** `false` <br> Enable or disable the confirmation E-Mail for new users. | | ||
| `signup.conf_code_expiry` | **Datatype:** Integer <br> **Default:** `5` <br> The time in minutes until the confirmation code expires. | | ||
| `signup.conf_code_complexity` | **Datatype:** Integer <br> **Default:** `1` <br> The complexity of the confirmation code. <br> **Possible Values** <br> <ul><li>**1**: `4 Digit Numeric`</li><li>**2**: `6 Digit Numeric`</li><li>**3**: `4 Characters`</li><li>**4**: `6 Characters`</li></ul> | | ||
| `signup.enable_welcome_email` | **Datatype:** Boolean <br> **Default:** `false` <br> Enable or disable the welcome E-Mail for new users. | | ||
|
||
|
||
### E-Mail Configuration | ||
|
||
!!! Warning "SMTP SSL required" | ||
EZAuth uses SMTP_SSL to send E-Mails. Make sure that your SMTP server supports SSL. | ||
Currently EZAuth does not support STARTTLS. | ||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `email.login_usr` | **Datatype:** String <br> **Default:** `""` <br> E-Mail Login Identifier (mostly the E-Mail itself). <br> **Example:** [email protected] | | ||
| `email.login_pwd` | **Datatype:** String <br> **Default:** `""` <br> E-Mail Login Password. | | ||
| `email.sender_email` | **Datatype:** String <br> **Default:** `""` <br> E-Mail address from which the E-Mails are sent (mostly the same as `email.login_usr`) | | ||
| `email.smtp_host` | **Datatype:** String <br> **Default:** `""` <br> SMTP Host for the E-Mail server. <br> **Example:** `smtp.gmail.com` | | ||
| `email.smtp_port` | **Datatype:** Integer <br> **Default:** `465` <br> SMTP Port for the E-Mail server. | | ||
|
||
### Session Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `session.session_expiry_seconds` | **Datatype:** Integer <br> **Default:** `86400` <br> The time in seconds until a login session expires. Expires on Client (Browser) and on the Server (Database). | | ||
| `session.max_session_count` | **Datatype:** Integer <br> **Default:** `5` <br> Maximum amount of sessions for one User. | | ||
| `session.auto_cookie` | **Datatype:** Boolean <br> **Default:** `true` <br> Specifies if the API should automatically return a `Set-Cookie` header to potentially automatically set the Session Token for the client. May simplify upcoming requests to this API. | | ||
| `session.auto_cookie_name` | **Datatype:** String <br> **Default:** `"session"` <br> The name of the cookie which will be set by the API. | | ||
|
||
### Internal API Configuration | ||
|
||
!!! danger "Internal API Key" | ||
Change this **immediately** after cloning the repository. Keeping the default value is a **severe security risk**. | ||
|
||
| Parameter | Description | | ||
|------------|-------------| | ||
| `internal.internal_api_key` | **Datatype:** String <br> **Default:** `"CHANGE_ME_NOW"` <br> This is **sensitive** information and must **never** be exposed anywhere. | | ||
| `internal.internal_columns` | **Datatype:** List <br> **Default:** `["_id"]` <br> Columns that should only be revealed via the internal API. This example will never reveal `_id` to public endpoints, but just to the `/internal` endpoints as well as E-Mails. | | ||
| `internal.not_updateable_columns` | **Datatype:** List <br> **Default:** `["email"]` <br> Columns that should not be able to get updated via the public API. | | ||
|
||
### Account Features Configuration | ||
| Parameter | Description | | ||
|------------|-------------| | ||
| `account_features.enable_reset_pswd` | **Datatype:** Boolean <br> **Default:** `true` <br> Enable or disable the password reset feature. | | ||
| `account_features.reset_pswd_conf_mail` | **Datatype:** Boolean <br> **Default:** `true` <br> Enable or disable the password change confirmation E-Mail. | | ||
| `account_features.2fa.enable` | **Datatype:** Boolean <br> **Default:** `false` <br> Enable or disable two factor for Login. 2FA was tested with [Google Authenticator](https://support.google.com/accounts/answer/1066447) and [2FAS Auth](https://2fas.com/) | | ||
| `account_features.2fa.issuer_name` | **Datatype:** String <br> **Default:** `"EZAuth"` <br> How the two factor code will be titled in the users 2FA App. (Mostly the App Name) | | ||
| `account_features.2fa.issuer_image_url` | **Datatype:** String <br> **Default:** `""` <br> URL for an optional Image which will be displayed in the 2FA App. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.