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

Adding bulk-import accounts using csv sample file #976

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

Shadow243
Copy link
Member

@Shadow243 Shadow243 commented Apr 25, 2024

Email Account Configuration for Cypht

This repository contains the account configuration settings for the Cypht. Unlike an approach based on directly storing configuration settings in the code (ex: config/account.php), we have opted to use a CSV file for configuring accounts.

Related Issue: #974

Data Isolation

By storing configuration settings in a CSV file, each user can have their own distinct configuration file. This allows for data isolation, ensuring that each user only has access to their own configured accounts and cannot access accounts configured by other users.

Example CSV File Structure:

Screenshot 2024-04-25 at 20 59 10

This is the display

Screenshot 2024-04-25 at 21 05 32

@Shadow243 Shadow243 marked this pull request as draft April 25, 2024 18:02
@Shadow243
Copy link
Member Author

I chose a CSV file instead of, for example:

<?php

return [
    /*
    | -------------------------------------
    | Constants used for auto configs servers and profiles
    | -------------------------------------
    |
    | These accounts are used to automatically configure the server and profile
    | When you add a new one don't forget to add env variables to .env file with the same name you are using here
    | just make sure names are unique to avoid conflicts. ex: PERSONAL_JMAP_SERVER
    | In case you are not putting env variables, you can set the value directly here
    | ex: 'server_name' => 'Migadu'
    |
    */
    'support_server_accounts' => env('SUPPORT_AUTO_ACCOUNTS_CONFIG', false),

    'server_accounts' => [
        'Personal' => [
            /*
            | When this is set to true, only server_name, email_or_username, password and host are required
            */
            'jmap_server' => env('PERSONAL_JMAP_SERVER', false),
            /*
            | This is the server name
            | ex: Migadu, Gandi, Postale, etc...
            */
            'server_name' => env('PERSONAL_SERVER_NAME', ''),
            /*
            | This is the server username or email
            */
            'email_or_username' => env('PERSONAL_SERVER_USERNAME', ''),
            /*
            | This is the server password
            */
            'password' => env('PERSONAL_SERVER_PWD', ''),
            /*
            | This is the port to used to connect to the server
            */
            'port' => env('PERSONAL_SERVER_PORT', 993),
            /*
            | Flag to enable or disable TLS connections
            */
            'tls' => env('PERSONAL_SERVER_TLS', true),
            /*
            | This is the host to connect to (the imap host address)
            */
            'host' => env('PERSONAL_SERVER_HOST', ''),
            /*
            | This is used to enable or disable the smtp support for this server
            */
            'support_smtp' => env('PERSONAL_SERVER_SUPPORT_SMTP', true),
            /*
            | if support_smtp is set to true, this is the smtp server to connect to
            */
            'smtp' => [
                /*
                | This is the smtp server to connect to
                */
                'server' => env('PERSONAL_SMTP_SERVER_HOST', ''),
                /*
                | This is the port to connect to the smtp server
                */
                'port' => env('PERSONAL_SMTP_SERVER_PORT', 465),
                /*
                | Flag to enable or disable TLS connections
                */
                'tls'=> env('PERSONAL_SMTP_SERVER_TLS', true)
            ]
        ],
    ],
];

@kroky
Copy link
Member

kroky commented Apr 26, 2024

@Shadow243 thanks for this but that's not a declarative config. You still need UI to import the csv. It also has problems with storing passwords in plain text. However, if it opens use-cases when people want to bulk-import accounts, then it is fine.

@Shadow243
Copy link
Member Author

@Shadow243 thanks for this but that's not a declarative config. You still need UI to import the csv. It also has problems with storing passwords in plain text. However, if it opens use-cases when people want to bulk-import accounts, then it is fine.

Most definitely @kroky, in this case I will keep the config way too. this will be a bit tricky though for multiple users in one instance.

Any suggestions about that ?

@kroky
Copy link
Member

kroky commented Apr 26, 2024

As I suggested in #974 - user can copy either the file system settings or the db settings to another machine to make it easier to transfer multiple accounts that are already setup. I don't think we need any config updates in that case.

@Shadow243 Shadow243 changed the title Adding multiple server connection using csv sample file Adding bulk-import accounts using csv sample file Apr 26, 2024
@TheDigitalOrchard
Copy link
Contributor

TheDigitalOrchard commented Apr 29, 2024

My 2¢, if such a plain-text file were to be introduced for this, I'd suggest using something like YAML which gives a richer structure and helps to avoid the "endless horizontal field list" that is prevalent in the world of using 2-dimensional tables (which we see with sprawling SQL tables, for example).

Just to show a snippet of the benefits of a format like YAML:

Migadu:
    servers:
        jmap:
            hostname:  jmap.abc.com
        imap:
            hostname:  imap.abc.com
        smtp:
            hostname:  smtp.abc.com
            port:      485
            tls:       true

It's human-readable while offering a richer structure that is future-proofed for growth.

But I agree with the concerns around storing credentials in a plaintext file. That's a no-no.

@marclaporte
Copy link
Member

marclaporte commented May 1, 2024

Please also see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat and #470

I'm looking for a good way to parse XML file.

@Shadow243 Shadow243 force-pushed the add-accounts-auto-connect branch 2 times, most recently from de7dbf0 to 6c46733 Compare May 16, 2024 20:16
@Shadow243 Shadow243 marked this pull request as ready for review May 16, 2024 20:17
composer.json Outdated Show resolved Hide resolved
@Shadow243 Shadow243 force-pushed the add-accounts-auto-connect branch 3 times, most recently from dd04ed3 to 3b177dc Compare June 20, 2024 10:30
modules/nux/assets/data/server_accounts_sample.yaml Outdated Show resolved Hide resolved
modules/nux/assets/data/server_accounts_sample.yaml Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
modules/nux/modules.php Outdated Show resolved Hide resolved
@Shadow243 Shadow243 force-pushed the add-accounts-auto-connect branch 4 times, most recently from 3b0631b to 075211b Compare August 3, 2024 16:20
@Shadow243 Shadow243 force-pushed the add-accounts-auto-connect branch 7 times, most recently from 3d07942 to b552369 Compare August 9, 2024 12:39
@Shadow243
Copy link
Member Author

@josaphatim anything to change here ?

@josaphatim josaphatim force-pushed the add-accounts-auto-connect branch 6 times, most recently from 286814b to cbb1765 Compare August 30, 2024 16:12
@Shadow243 Shadow243 requested a review from kroky August 30, 2024 16:29
@josaphatim
Copy link
Member

@kroky can you check please ?

Copy link
Member

@kroky kroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@josaphatim josaphatim merged commit 315dd1a into cypht-org:master Sep 12, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants