Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(config): update SMTP config instructions #9090

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 180 additions & 68 deletions docs/admin/config-guide/smtp-configuration.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,232 @@
---
tags:
- administration
- configuration
- smtp
- administration
- configuration
- smtp
---

# SMTP Configuration

> Prerequisite: Know how to use the Janssen CLI in [command-line mode](config-tools/jans-cli/README.md)
The Janssen Server provides multiple configuration tools to perform these
tasks.

Let's get the information of **SMTP Configuration** using Janssen CLI.

```commandline
/opt/jans/jans-cli/config-cli.py --info ConfigurationSMTP
=== "Use Command-line"

Use the command line to perform actions from the terminal. Learn how to
use Jans CLI [here](./config-tools/jans-cli/README.md) or jump straight to
the [Using Command Line](#using-command-line)

=== "Use Text-based UI"

Use a fully functional text-based user interface from the terminal.
Learn how to use Jans Text-based UI (TUI)
[here](./config-tools/jans-tui/README.md) or jump straight to the
[Using Text-based UI](#using-text-based-ui)

=== "Use REST API"

Use REST API for programmatic access or invoke via tools like CURL or
Postman. Learn how to use Janssen Server Config API
[here](./config-tools/config-api/README.md) or Jump straight to the
[Using Configuration REST API](#using-configuration-rest-api)



## Using Command Line


In the Janssen Server, you can deploy and customize the SMTP using the
command line. To get the details of Janssen command line operations relevant to
SMTP Configuration, you can check the operations under `ConfigurationSmtp`
task using the command below:

```bash title="Command"
/opt/jans/jans-cli/config-cli.py --info ConfigurationSmtp
```


```text title="Sample Output"
Operation ID: get-config-smtp
Description: Returns SMTP server configuration.
Operation ID: post-config-smtp
Description: Adds SMTP server configuration.
Schema: /components/schemas/SmtpConfiguration
Description: Returns SMTP server configuration
Operation ID: put-config-smtp
Description: Updates SMTP server configuration.
Schema: /components/schemas/SmtpConfiguration
Description: Updates SMTP server configuration
Schema: SmtpConfiguration
Operation ID: post-config-smtp
Description: Adds SMTP server configuration
Schema: SmtpConfiguration
Operation ID: delete-config-smtp
Description: Deletes SMTP server configuration.
Description: Deletes SMTP server configuration
Operation ID: test-config-smtp
Description: Test SMTP server configuration.

To get sample schema type /opt/jans/jans-cli/config-cli.py --schema <schema>, for example /opt/jans/jans-cli/config-cli.py --schema /components/schemas/SmtpConfiguration
Description: Signing Test SMTP server configuration
Schema: SmtpTest
```
As we see, we can perform many operations such as `update`, `delete`, `test`, `post`, etc. Let's do some operations.

## Find SMTP Server Configuration

### Find SMTP Server Configuration

To view the current SMTP server configuration, run the following command line:

```commandline
```bash title="Command"
/opt/jans/jans-cli/config-cli.py --operation-id get-config-smtp
```

It will show your SMTP server configuration as below:
It will show the SMTP server configuration as below:

```text
Getting access token for scope https://jans.io/oauth/config/smtp.readonly
```json title="Sample Output" linenums="1"
{
"host": "webmail.gluu.org",
"port": 587,
"requiresSsl": null,
"serverTrust": null,
"fromName": null,
"fromEmailAddress": null,
"requiresAuthentication": null,
"userName": null,
"password": "fHze8OEMs1MzkGhWw/29eg=="
"valid": false,
"port": 0,
"trust_host": false,
"requires_authentication": false,
"key_store": "/etc/certs/smtp-keys.pkcs12",
"key_store_password": "kb5JITTrmCyX1LNEp8uorA==",
"key_store_alias": "smtp_sig_ec256",
"signing_algorithm": "SHA256withECDSA"
}
```

## Setup New SMTP Server Configuration
### Setup New SMTP Server Configuration



This operation can be performed to update/post a new SMTP configuration on your Janssen server.
Let's see the schema first:
To add a new SMTP Server, we can use `post-config-smtp` operation id.
As shown in the [output](#using-command-line) for`--info`
command, the `post-config-smtp` operation requires data to be sent
according to the `SmtpConfiguration` schema.

```commandline
/opt/jans/jans-cli/config-cli.py --schema /components/schemas/SmtpConfiguration > /tmp/smtp.json
To see the schema, use the command below:
```bash title="Command"
/opt/jans/jans-cli/config-cli.py --schema SmtpConfiguration
```

It will create a `.json` file. Let's modify this file:
The Janssen Server also provides an example of data that adheres to the above schema.
To fetch the example, use the command below.

```commandline
nano /tmp/smtp.json
```bash title="Command"
/opt/jans/jans-cli/config-cli.py --schema-sample SmtpConfiguration
```

![smtp update configuration](../../assets/image-cl-update-smtp-03042021.png)
Using the schema and the example above, we have added below data to the file
`/tmp/smtp.json`.

You can update each of its properties. To perform this operation, run the following command:

```commandline
/opt/jans/jans-cli/config-cli.py --operation-id post-config-smtp --data /tmp/smtp.json
```json title="Input" linenums="1"
{
"valid": true,
"host": "string",
"port": 5,
"connect_protection": "StartTls",
"trust_host": false,
"from_name": "jans",
"from_email_address": "string",
"requires_authentication": false,
"smtp_authentication_account_username": "string",
"smtp_authentication_account_password": "string",
"key_store": "string",
"key_store_password": "string",
"key_store_alias": "string",
"signing_algorithm": "string"
}
```

To setup a new SMTP server configuration, run the following command:

```bash title="Command"
/opt/jans/jans-cli/config-cli.py --operation-id post-config-smtp \
--data /tmp/smtp.json
```

If you run the following command, it will update your janssen smtp server and print on the screen as below.

```text
Getting access token for scope https://jans.io/oauth/config/smtp.write
Server Response:
```json title="Sample Output" linenums="1"
{
"host": "webmail.gluu.org",
"port": 587,
"requiresSsl": null,
"serverTrust": null,
"fromName": null,
"fromEmailAddress": null,
"requiresAuthentication": null,
"userName": null,
"password": "fHze8OEMs1MzkGhWw/29eg=="
"valid": true,
"host": "string",
"port": 5,
"connect_protection": "StartTls",
"trust_host": false,
"from_name": "jans",
"from_email_address": "string",
"requires_authentication": false,
"smtp_authentication_account_username": "string",
"smtp_authentication_account_password": "CGmVqM6v4Hs=",
"key_store": "string",
"key_store_password": "CGmVqM6v4Hs=",
"key_store_alias": "string",
"signing_algorithm": "string"
}
```

## Update SMTP Server Configuration

To update smtp server, simply change any information on `/tmp/smtp.json` file and run the following command:
### Update SMTP Server Configuration

To update the SMTP server, we can use the `put-config-smtp` operation id.
simply change any information on `/tmp/smtp.json`file and run the following
command:

```commandline
/opt/jans/jans-cli/config-cli.py --operation-id put-config-smtp --data /tmp/smtp.json
In that file, update the value `false` to `true` of the `trust_host` field.

```bash title="Command"
/opt/jans/jans-cli/config-cli.py --operation-id put-config-smtp \
--data /tmp/smtp.json
```
It will update the information.


## Test SMTP Server Configuration
Testing SMTP configuration token with `https://jans.io/oauth/config/smtp.write` scope is required.
To test SMTP configuration update, change any information on `/tmp/smtp.json` file with test data and run the following command:

```commandline
/opt/jans/jans-cli/config-cli.py --operation-id test-config-smtp --data /tmp/smtp.json
### Delete SMTP Sever Configuration

To delete the SMTP Sever, we can use the `delete-config-smtp` operation id.
run the following command

```bash title="Command"
/opt/jans/jans-cli/config-cli.py --operation-id delete-config-smtp
```


### Test SMTP Server Configuration

Testing SMTP Server configuration token with `https://jans.io/oauth/config/smtp.write`
scope is required. To test the SMTP server configuration update, change any information
on the `/tmp/smtp.json` file with test data and run the following command:

```bash title="Command"
/opt/jans/jans-cli/config-cli.py --operation-id test-config-smtp \
--data /tmp/smtp.json
```
This will be return status code 200 with response as true or false based on the SMTP test result.
Note: `SMTP Password` should be App password and not web login password.
This will return status code 200 with a response as true or false based on the
SMTP test result.
Note: `SMTP Password` should be an App password and not a web login password.



## Using Text-based UI

Start TUI using the command below:

```bash title="Command"
sudo /opt/jans/jans-cli/jans_cli_tui.py
```

### SMPT Screen

Navigate to `Auth Server` -> `SMPT` to open the SMPT screen as shown
in the image below.

![image](../../assets/tui-smtp.png)

* This screen shows the current SMTP server configuration.
* After changing the SMPT data, update the SMPT server using the `Save` button.
* Test the SMPTS server using the `Test` button, and the result will be displayed.

The test result image is shown below.

![image](../../assets/tui-smtp-result.png)


## Using Configuration REST API

Janssen Server Configuration REST API exposes relevant endpoints for managing
and configuring the SMTP. Endpoint details are published in the [Swagger
document](./../reference/openapi.md).

Binary file added docs/assets/tui-smtp-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tui-smtp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.