I have configured my application to work with multiple databases. The magic works just fine. In my Bootstrap.php I have defined the folowing:
protected function _initDb()
{
$resource = $this->getPluginResource('multidb');
Zend_Registry::set("multidb", $resource);
}
and in my application.ini:
resources.multidb.db1.adapter = mysqli
resources.multidb.db1.host = localhost
resources.multidb.db1.username = user
resources.multidb.db1.password = pass
resources.multidb.db1.dbname = db
resources.multidb.db1.charset= "utf8"
resources.multidb.db1.default= true
resources.multidb.db1.profiler.enabled = true
resources.multidb.oracle.adapter = oracle
resources.multidb.oracle.username = user
resources.multidb.oracle.password = pass
resources.multidb.oracle.charset= "utf8"
resources.multidb.oracle.dbname = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(Host = host.example.com) (Port = 1529)) (CONNECT_DATA = (SID = DB)))"
resources.multidb.oracle.profiler.enabled = true
All of this works just fine. In my models, I usually do something like this in the init():
$multidb = Zend_Registry::get("multidb");
$this->oracle = $multidb->getDb('oracle');
But I recently wanted to move this part to the Bootstrap, or rather, Registry, like this:
protected function _initDb()
{
$resource = $this->getPluginResource('multidb');
Zend_Registry::set("multidb", $resource);
Zend_Registry::set("odb",$resource->getDb('oracle'));
}
And this is what happened:
Fatal error: Uncaught exception 'Zend_Application_Resource_Exception' with message 'A DB adapter was tried to retrieve, but was not configured' in C:\Zend\Apache2\htdocs\Zend\Application\Resource\Multidb.php on line 135
I know a temporary fix around this, but why is this happening, and what could be a more long term fix, so that I could set each adapter in registry, preferably in bootstrap?
Thanks!
I think you have to make sure the multidb resource is bootstrapped in other to be filled. You can do this with the following:
protected function _initDb() {
$this->bootstrap('multidb');
$resource = $this->getPluginResource('multidb');
Zend_Registry::set("multidb", $resource);
Zend_Registry::set("odb",$resource->getDb('oracle'));
}
Related
I am able to create a azurerm_postgresql_flexible_server and azurerm_postgresql_flexible_server_database using terraform.
I am not able to create a schema using TF but not able to get much help on documentation.
I also checked https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs/resources/postgresql_schema
but that uses a different provider. I am not sure what am I missing here.
This is the TF template which creates the Azure PostgreSQL server and DB -
module "common_modules" {
source = "../modules/Main"
}
provider "azurerm" {
features {}
}
locals {
#Construct Tag Data for Resource
resourceTags = {
environment = var.environment
createdBy = var.createdBy
managedBy = var.managedBy
colorBand = var.colorBand
purpose = var.purpose
lastUpdateOn = formatdate("DD-MM-YYYY hh:mm:ss ZZZ", timestamp())
}
}
resource "azurerm_postgresql_flexible_server" "postgreSQL" {
name = var.postgreSQL
location = var.location
resource_group_name = var.ckeditorResorceGroup
administrator_login = var.postgreSQLAdmin
administrator_password = var.password
sku_name = "B_Standard_B1ms"
version = "13"
storage_mb = 32768
backup_retention_days = 7
geo_redundant_backup_enabled = false
tags = local.resourceTags
}
resource "azurerm_postgresql_flexible_server_database" "postgreSQLDB" {
name = var.postgreSQLDB
server_id = azurerm_postgresql_flexible_server.postgreSQL.id
collation = "en_US.utf8"
charset = "utf8"
}
resource "azurerm_postgresql_flexible_server_firewall_rule" "postgreSQLFirewallRule" {
name = "allow_access_to_azure_services"
server_id = azurerm_postgresql_flexible_server.postgreSQL.id
start_ip_address = "0.0.0.0"
end_ip_address = "0.0.0.0"
}
have a look at https://registry.terraform.io/providers/cyrilgdn/postgresql or https://github.com/cyrilgdn/terraform-provider-postgresql
usable, but you need network connectivity to resolve names (azure private dns zone) and to connect with postgresql flexible server. The terraform code should run in same vnet like flexi server.
Here is my config:
["quartz.jobStore.dataSource"] = "default",
["quartz.jobStore.tablePrefix"] = "QRTZ_",
["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.PostgreSQLDelegate, Quartz",
["quartz.dataSource.default.provider"] = "Npgsql",
["quartz.dataSource.default.connectionString"] = #"User ID=ttt;Password=xxx;Host=ttt.postgres;Port=5432;Database=ttt;"
Exception:
Could not parse property 'dataSource' into correct data type: No writable property 'DataSource' found
I've been trying different things for over an hour, the docs don't really help (slim on the examples front) and I've tried to dig through the Quartz.Net source but no luck :/
Adding this seems to have fixed it - i'm not 100% up and running but I have gotten further...
properties["quartz.scheduler.instanceName"] = "SonatribeScheduler";
properties["quartz.scheduler.instanceId"] = "instance_one";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "10";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
I have been trying to integrate sendGrid with PHPList. Sad I couldn't find any latest article / document on same.
I tried changing config/config.php file. here is the code [edits],
define('PHPMAILERHOST', 'smtp.sendgrid.net');
$phpmailer_smtpuser = 'uname';
$phpmailer_smtppassword = 'pass';
define("PHPMAILER_SECURE",'tls');
## you can set this to send out via a different SMTP port
define('PHPMAILERPORT', 587);
I also tried to edit setupdir/admin/phpMailer/class.phpmailer.php. Here is how it looks [changed lines],
public $Host = 'smtp.sendgrid.net';
public $Port = 587;
public $Helo = '';
public $SMTPSecure = 'tsl';
public $SMTPAutoTLS = true;
public $SMTPAuth = true;
public $Username = 'myusername';
public $Password = 'mypass';
I tried both but its not working. Can someone point me to exact place I need to change code?
Thanks,
You've got TSL in the config instead of TLS.
I've created an application and been using Shiro for the authentication.
I've followed most of the guides and also some of the posted questions here regarding shiro and Jdbc Realm.
Here is my shiro.ini file:
[main]
authc.loginUrl=/jsp/loginForm.jsp
authc.successUrl=/test/successUrl.jsp
authc.rememberMeParam = login-remember-me
logout.redirectUrl=/index.jsp
hashService = org.apache.shiro.crypto.hash.DefaultHashService
hashService.hashIterations = 500000
hashService.hashAlgorithmName = SHA-256
hashService.generatePublicSalt = true
hashService.privateSalt = someBase64EncodedSaltValue
realm = org.apache.shiro.realm.jdbc.JdbcRealm
realm.permissionsLookupEnabled = false
realm.authenticationQuery = SELECT password FROM userTable WHERE username = ?
ps = org.apache.shiro.authc.credential.DefaultPasswordService
ps.hashService = $hashService
pm = org.apache.shiro.authc.credential.PasswordMatcher
pm.passwordService = $ps
jof = org.apache.shiro.jndi.JndiObjectFactory
jof.resourceName = java:comp/env/jdbc/theResourceName
jof.requiredType = javax.sql.DataSource
jof.resourceRef = true
realm.dataSource = $jof
realm.credentialsMatcher = $pm
securityManager.realms = $realm
and i'm using the following code in Java to save the password in the database:
DefaultHashService hashService = new DefaultHashService();
hashService.setHashIterations(500000);
hashService.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME);
hashService.setPrivateSalt(new SimpleByteSource(
"someBase64EncodedSaltValue")); // Same salt as in shiro.ini, but NOT
// base64-encoded.
hashService.setGeneratePublicSalt(true);
DefaultPasswordService pwService = new DefaultPasswordService();
pwService.setHashService(hashService);
this.password = pwService.encryptPassword(password);
Everything looks good and is saving as expected but the problem is when I am logging in. I've traced the execution to JdbcRealm.class and I've seen that the value compared is the "raw string password" and the encrypted password from the database.
Did I miss any step configuring?
To use Salted its better to have seperate salt for every user. So store that salt in database. SEE
Now,
Extend org.apache.shiro.realm.jdbc.JdbcRealm like:
package common.shiro;
import org.apache.shiro.realm.jdbc.JdbcRealm;
public class JDBCSaltedRealm extends JdbcRealm {
public JDBCSaltedRealm() {
setSaltStyle(SaltStyle.COLUMN);
}
}
In shiro.ini:
credentialsMatcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher
credentialsMatcher.hashAlgorithmName=SHA-256
credentialsMatcher.storedCredentialsHexEncoded = false
credentialsMatcher.hashIterations = 500000
credentialsMatcher.hashSalted = true
realm = common.shiro.JDBCSaltedRealm
realm .permissionsLookupEnabled = true
realm .authenticationQuery = SELECT password,salt FROM userTable WHERE username = ?
realm .dataSource = $jof
realm .credentialsMatcher = $credentialsMatcher
securityManager.realm = $realm
Hi i´m trying to bind mongodb service on my expressjs app with Appfog.
I have a config file like this:
config.js
var config = {}
config.dev = {};
config.prod = {};
//DEV
config.dev.host = "localhost";
config.dev.port = 3000;
config.dev.mdbhost = "localhost";
config.dev.mdbport = 27017;
config.dev.db = "detysi";
//PROD
config.prod.service_type = "mongo-1.8";
config.prod.json = process.env.VCAP_SERVICES ? JSON.parse(process.env.VCAP_SERVICES) : '';
config.prod.credentials = process.env.VCAP_SERVICES ? config.prod.json[config.prod.service_type][0]["credentials"] : null;
config.prod.mdbhost = config.prod.credentials["host"];
config.prod.mdbport = config.prod.credentials["port"];
config.prod.db = config.prod.credentials["db"];
config.prod.port = process.env.VCAP_APP_PORT || process.env.PORT;
module.exports = config;
And this is my mongodb conf depending of the environment
app.js
if ( process.env.VCAP_SERVICES ) {
server = new Server(config.prod.mdbhost, config.prod.mdbport, { auto_reconnect: true });
db = new Db(config.prod.db, server);
} else {
server = new Server(config.dev.mdbhost, config.dev.mdbport, { auto_reconnect: true });
db = new Db(config.dev.db, server);
}
I bind the service manually from https://console.appfog.com, my app is using the infra AWS Virginia. I also use MongoHQ addon to create one collection with two documents.
When i go to Windows console and write af update myapp it throws me next error:
Cannot read property '0' of undefined
This is cause process.env.VCAP_SERVICES is undefined.
I was investigating that and it can be that my mongodb service is incorrectly binded.
After that i tried to bind mongodb service from the windows console like below:
af bind-service mongodb myapp
But it throws me next error:
Service mongodb and App myapp are not on the same infra
At this point i don´t know what can i do.
I had the same problem.
What fixed it for me:
Go to: console>services>(re)start mongodb service
Run the same command again.
Push again.
It should work.