grails / grails-mail

The Grails Mail Plugin
https://grails.github.io/grails-mail/
Apache License 2.0
14 stars 25 forks source link

Support for External Credentials Provider #38

Open dustindclark opened 5 years ago

dustindclark commented 5 years ago

This is a feature request. Looking for a clean way to inject an external credentials provider so that I don't have to store plain text credentials in SCM, environment variables, JVM startup params, etc. This is the only workaround that I've found, and obviously it's not a good one:

@CompileStatic
class BootStrap {
    SecretManagerService secretManagerService
    MailSender mailSender

    def init = { servletContext ->
        final Secret secret = secretManagerService.getSecret('my-secret-name')
        setMailPassword(secret)
    }

    @CompileDynamic
    void setMailPassword(final Secret secret) {
        //TODO: this is really bad.
        mailSender.username = secret.username
        mailSender.password = secret.password
    }
}

Obviously the default implmentation should remain as-is and use config, but I would like to inject my credential manager accordingly. Thanks!