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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 marked this pull request as ready for review May 16, 2024 20:17
jmap:
jmap_server:
user:
username: [email protected]
Copy link
Member

Choose a reason for hiding this comment

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

Please use https://example.org for fake data

@@ -38,6 +38,7 @@
"paragonie/random_compat": "^2.0.18",
"php": ">=7.4",
"symfony/dotenv": "^4.3 || 5.4",
"symfony/yaml": "^5.4",
Copy link
Member

Choose a reason for hiding this comment

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

It's good that you took same component as Tiki: https://gitlab.com/tikiwiki/tiki/-/blob/master/vendor_bundled/composer.json

'nux_all_inkl_login' => FILTER_DEFAULT,
'accounts_source' => FILTER_DEFAULT,
'accounts_source' => FILTER_DEFAULT,
'accounts_csv' => FILTER_DEFAULT,
)
Copy link
Member

Choose a reason for hiding this comment

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

so it is csv, yaml or both?

Copy link
Member Author

Choose a reason for hiding this comment

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

This on is using yaml for now. Should i add csv too or just remove any mention of it ??

Copy link
Member

Choose a reason for hiding this comment

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

Should i add csv too or just remove any mention of it ?

@TheDigitalOrchard You suggested YAML. What do you think?

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.

None yet

4 participants