I'm having issues getting sfGuard
token login working with a Symfony app. The Symfony app is accessed through WordPress plugin. The WordPress plugin is bare bones which embeds a iframe
with a token string in the WP control panel:
<iframe src="/app/index.php/api/authenticate/**token**" width="100%" height="100%">
This works fine on the live server. After digging through my error logs I found this:
PDO Connection Error: SQLSTATE[28000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES), referer: http://****/wp-admin/admin.php?page=custom-sms.php
PHP Fatal error: Call to a member function prepare() on a non-object in /var/www/vhosts/domain.com/sfapp/lib/vendor/symfony/lib/storage/sfPDOSessionStorage.class.php on line 162, referer: http://****/wp-admin/admin.php?page=custom-sms.php
The odd thing is though I'm able to write/connect to the database on the front-end of the site. What could be causing the app not to use the database username and password set in the database.yml
config file?
The app.yml
file:
all:
security:
#to auto-login to the SMS alert system from inside Wordpress admin
token: **token**
username: [email protected]
BTW, I've never used Symfony before and I inherited this site with no documentation.
database.yml
file:
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/07-Databases
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: mysql:host=localhost;dbname=db_name
username: **username**
password: **password**
To add, I manually set the $env
variable to prod
for testing /web/index.php
on the new server.
factories.yml
file:
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/05-Factories
prod:
logger:
class: sfAggregateLogger
param:
level: err
loggers:
sf_file_debug:
class: sfFileLogger
param:
level: err
file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
staging:
logger:
class: sfAggregateLogger
param:
level: notice
loggers:
sf_file_debug:
class: sfFileLogger
param:
level: notice
file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
test:
storage:
class: sfSessionTestStorage
param:
session_path: %SF_TEST_CACHE_DIR%/sessions
response:
class: sfWebResponse
param:
send_http_headers: false
mailer:
param:
delivery_strategy: none
all:
routing:
class: sfPatternRouting
param:
generate_shortest_url: true
extra_parameters_as_query_string: true
view_cache_manager:
class: sfViewCacheManager
param:
cache_key_use_vary_headers: true
cache_key_use_host_name: true
Got it working. All credit goes to @j0k for the pointers.
During setup on the new server I was hitting some errors with the session storage, so I changed the storage class type on the [app]/config/factories.yml
to sfNoStorage
. Reverting back to sfPDOSessionStorage
allows the token login to work.
all:
storage:
#http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/
class: sfPDOSessionStorage
param:
session_name: ugro
database: doctrine
db_table: session
db_id_col: sess_id
db_data_col: sess_data
db_time_col: sess_time