diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2025-03-09 01:53:44 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 01:53:44 +1100 |
| commit | 9241731a4dd5592b4a02b5352c903b4d06b6f4ab (patch) | |
| tree | 5184b98751912a261ff70fd8721b9cd4f1c98f1e /internal/storage/sql_provider.go | |
| parent | bbcb38ab9ff35e69d5d52a71ab56346749f5e8b1 (diff) | |
feat(embed): make authelia embedable (#8841)
This adds a highly experimental option for developers looking to embed Authelia within another go binary.
Closes #5803
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/storage/sql_provider.go')
| -rw-r--r-- | internal/storage/sql_provider.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/storage/sql_provider.go b/internal/storage/sql_provider.go index d738cd80c..3ba918b87 100644 --- a/internal/storage/sql_provider.go +++ b/internal/storage/sql_provider.go @@ -3,6 +3,7 @@ package storage import ( "context" "crypto/sha256" + "crypto/x509" "database/sql" "errors" "fmt" @@ -19,6 +20,20 @@ import ( "github.com/authelia/authelia/v4/internal/model" ) +// NewProvider dynamically initializes a storage.Provider given a *schema.Configuration and *x509.CertPool. +func NewProvider(config *schema.Configuration, caCertPool *x509.CertPool) (provider Provider) { + switch { + case config.Storage.PostgreSQL != nil: + return NewPostgreSQLProvider(config, caCertPool) + case config.Storage.MySQL != nil: + return NewMySQLProvider(config, caCertPool) + case config.Storage.Local != nil: + return NewSQLiteProvider(config) + default: + return nil + } +} + // NewSQLProvider generates a generic SQLProvider to be used with other SQL provider NewUp's. func NewSQLProvider(config *schema.Configuration, name, driverName, dataSourceName string) (provider SQLProvider) { db, err := sqlx.Open(driverName, dataSourceName) |
