Skip to content

Commit 38c4c90

Browse files
committed
Introduce DB connection config
1 parent 9682bf3 commit 38c4c90

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

config/module_oidc.php.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ use SimpleSAML\Module\oidc\ModuleConfig;
2020
* However, all the key values have been preserved from previous module versions.
2121
*/
2222
$config = [
23+
/**
24+
* Database connection parameters, Doctrine DBAL compatible (more info on
25+
* https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html).
26+
* There are additional parameters for: table prefix.
27+
*/
28+
ModuleConfig::OPTION_DB_CONNECTION_PARAMETERS => [
29+
'driver' => 'pdo_mysql', // (string): The built-in driver implementation to use.
30+
'user' => 'user', // (string): Username to use when connecting to the database.
31+
'password' => 'password', // (string): Password to use when connecting to the database.
32+
'host' => 'host', // (string): Hostname of the database to connect to.
33+
'port' => 3306, // (integer): Port of the database to connect to.
34+
'dbname' => 'dbname', // (string): Name of the database/schema to connect to.
35+
//'unix_socket' => 'unix_socet', // (string): Name of the socket used to connect to the database.
36+
'charset' => 'utf8', // (string): The charset used when connecting to the database.
37+
//'url' => 'mysql://user:secret@localhost/mydb?charset=utf8', // ...alternative way of providing parameters.
38+
// Additional parameters not originally available in Doctrine DBAL
39+
'table_prefix' => '', // (string): Prefix for each table.
40+
],
41+
2342
/**
2443
* (optional) Issuer (OP) identifier which will be used as an issuer (iss) claim in tokens. If not set, it will
2544
* fall back to current HTTP scheme, host and port number if no standard port is used.

src/ModuleConfig.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class ModuleConfig
9898
final public const OPTION_PKI_FEDERATION_NEW_PRIVATE_KEY_PASSPHRASE = 'federation_new_private_key_passphrase';
9999
final public const OPTION_PKI_FEDERATION_NEW_PRIVATE_KEY_FILENAME = 'federation_new_private_key_filename';
100100
final public const OPTION_PKI_FEDERATION_NEW_CERTIFICATE_FILENAME = 'federation_new_certificate_filename';
101+
final public const OPTION_DB_CONNECTION_PARAMETERS = 'db_connection_parameters';
101102

102103
protected static array $standardScopes = [
103104
ScopesEnum::OpenId->value => [
@@ -241,6 +242,11 @@ public function config(): Configuration
241242
return $this->moduleConfig;
242243
}
243244

245+
public function getDbConnectionParameters(): array
246+
{
247+
return $this->config()->getArray(self::OPTION_DB_CONNECTION_PARAMETERS);
248+
}
249+
244250
// TODO mivanci v7 Move to dedicated \SimpleSAML\Module\oidc\Utils\Routes::getModuleUrl
245251
public function getModuleUrl(?string $path = null): string
246252
{

0 commit comments

Comments
 (0)