Need help in making BeSimpleSsoAuthBundle work with FOSUserBundle - php

I have successfully implemented the FOSUserbundle as stated on the the github site. However I also need to have my site work with BeSimpleSsoAuthBundle.
The use case is that a user can register on the site however if they have SSO, that they can still sign on (and create the user locally inadvertently). I have also installed the BeSimpleSsoAuthBundle bundle according to the github site
WHat I am trying to do is show user a login form and take those credentials and run them against the local database and if they do not match, then check the SSO server. In case the SSO server is OK with the credentials, I then create the user locally.
My security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"
my_firewall:
pattern: ^/admin/.*$
trusted_sso:
manager: admin_sso
login_action: BeSimpleSsoAuthBundle:TrustedSso:login
logout_action: BeSimpleSsoAuthBundle:TrustedSso:logout
create_users: true
created_users_roles: [ROLE_USER, ROLE_ADMIN]
access_control:
- { path: ^/demo/secured/hello/admin/, roles: ROLE_ADMIN }
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
My config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
trusted_hosts: ~
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ MainReferralCaptureBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Main\ReferralCaptureBundle\Entity\User
#be_simple_sso_auth: ~
be_simple_sso_auth:
admin_sso:
protocol:
id: cas
version: 2
server:
id: cas
login_url: http://cas.server.tld/login
logout_url: http://cas.server.tld/logout
validation_url: http://cas.server.tld/serviceValidate
Can someone help me with what I am trying to do?
Many many thanks in advance

Related

Symfony\Component\Config\Definition\Exception\InvalidTypeException on Symfony2.8

I'm trying to set a login with FosUserBundle on Synfony 2.8 but I gte this error when I try to start the server
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "security.firewalls.pattern". Expected array,
but got string
This is the security.yml file
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
# activate different ways to authenticate
# http_basic: ~
# http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
# form_login: ~
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
encoders:
UserBundle\Entity\User:
algorithm: bcrypt
cost: 12
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
and this is the config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#UserBundle/Resources/config/services.yml" }
parameters:
locale: en
framework:
translator: { fallbacks: [en] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: es
trusted_hosts: ~
trusted_proxies: ~
session:
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
I think I've followed the official doc but It doesn't work
It looks like you have to refactor yor firewalls:
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true

Unrecognized option “csrf_token_generator” under “security.firewalls.main.form_login”

I'm trying to install the FOSUserBundle following the tutorial: https://symfony.com/doc/master/bundles/FOSUserBundle/index.html
but appears the error :
InvalidConfigurationException: Unrecognized options "csrf_token_generator" under "security.firewalls.main.form_login"
My config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
csrf_protection:
enabled: true
#esi: ~
#translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Utilisateurs\UtilisateursBundle\Entity\Utilisateurs
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
My security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
csrf_provider: form.csrf_provider
logout: true
anonymous: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/demo/secured/login$
security: false
secured_area:
pattern: ^/demo/secured/
form_login:
check_path: _security_check
login_path: _demo_login
logout:
path: _demo_logout
target: _demo
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: ROLE_ADMIN }
enter code here
Can someone help me ?
The problem is in your security.yml file. You have listed two CSRF token managers.
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
Depending on what version of Symfony you are using you use either csrf_token_generator or csrf_provider if your version of Symfony is <2.8, not both.
You need to remove or comment one of the lines out.
Editing this post because I cannot comment on your new post.
My version symfony is 2.4 : "symfony/symfony": "2.4.*"
But i have these new error:
ServiceNotFoundException: You have requested a non-existent service "fos_user.doctrine_registry".
This could be due to your version of Symfony being <2.6.* and conflicting with the FOSUserBundle version you are using.
For a temporary work around edit your config.yml
services:
fos_user.doctrine_registry:
alias: doctrine
# or use this, unsure on which one for your version of Symfony
# alias: doctrine_mongodb
Other fixes could be using a particular pull (older version - not recommended) in your composer.json. This has been tested for Symfony 2.6.* and bypassing the same issue you posted.
"friendsofsymfony/user-bundle": "dev-master##6ccff96434c0ac7fee077d1dce90966341dfd278"
You can read more about this particular problem:
https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2048
A Symfony branch exists as a temporary fix as well:
https://github.com/symfony/symfony/pull/17554

Symfony 3 Problems FosUserBundle in resetting request

I had this message error 4 hours ago and I tried to resolve it but I didn't know where is the problem. Maybe all files are wrong configured? Login is OK.
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
default_target_path: /
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
remember_me: true
remember_me:
secret: %secret%
#lifetime: 30000000
logout: true
anonymous: true
logout:
path: /logout
target: /login
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
# - { path: ^/listeUsers, role: ROLE_SUPER_ADMIN }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin/, role: ROLE_ADMIN }
# - { path: ^/ajouter, role: ROLE_ADMIN }
- { path: ^/index, role: IS_AUTHENTICATED_ANONYMOUSLY}
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
#http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
translator: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: gmail
host: "%mailer_host%"
username: 'digita****#gmail.com'
password: '*******'
spool: { type: memory }
#FOS USERBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: digita***.code#gmail.com
sender_name: DigitalCode - Sestem | Resetting Password
But resetting/request doesn't work. It stayed on the login interface.
First Thunks Brother ,
u are right i make a mistake in the access_control , now it's working but with those configurations without ReGex :
access_control:
- { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
Problem Solved.
I think you have a misconfiguration in access_control:
see this
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
and compare it with this
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
I think this should work:
- { path: ^/resetting$, role: IS_AUTHENTICATED_ANONYMOUSLY }
Now it should be working. I can't explain it completely but for me since the regex delimiter is missing it seems to be like its used as given not as regex as you wanted to.

FOSUserBundle Authentication not working on production server

I am new to Symfony, and probably thats why i don't seem to be able to target where the certain bugs generate from.
A new problem popped up when i put my site on the production server, the FOSUserBundle Authentication doesn't seem to work
Note: This worked absolutely fine on localhost, but as soon as i put it on the distant server, it does not validate any user.
The web/config.php file recommends that i :
1) Install and enable the php_posix extension (used to colorize the CLI output).
2) Install and enable the intl extension (used for validators)
3) Install and enable a PHP accelerator like APC (highly recommended).
4) Set short_open_tag to off in php.ini*.
Could this cause problems in Authentication ?
my config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
translator: ~
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ LesCouvertsBundle , LesRestaurantBundle , LesVirtualMarketBundle , LesShopBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
encryption: ssl
auth_mode: login
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Les\UserBundle\Entity\User
registration:
confirmation:
from_email:
address: registration#lescouverts.com
sender_name: Lescouverts Registration
enabled: false
from_email:
address: noreply#lescouverts.com
sender_name: LesCouverts
services:
resto_module:
class: Les\RestoModule\Module
arguments: [module]
lists_module:
class: Les\RestoParam\Param
arguments: [parameters]
my security.yml file
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_CLIENT: ROLE_USER
ROLE_RESTO: ROLE_CLIENT
ROLE_SHOP: ROLE_CLIENT
ROLE_ADMIN: [ ROLE_USER, ROLE_CLIENT, ROLE_RESTO , ROLE_SHOP ]
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: fos_user_security_login
csrf_provider: form.csrf_provider
# check_path: /login_check
check_path: fos_user_security_check
default_target_path: /
csrf_provider: form.csrf_provider
logout:
path: fos_user_security_logout
anonymous: true
access_control:
- { path: ^/booking, role: ROLE_CLIENT }
- { path: ^/party_calendar, role: ROLE_CLIENT }
- { path: ^/restaurant_admin, role: ROLE_RESTO }
- { path: ^/shop_admin, role: ROLE_SHOP }
- { path: ^/virtual_market, role: [ ROLE_RESTO, ROLE_SHOP ] }
- { path: ^/root, role: ROLE_ADMIN }
- { path: ^/secure_area/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area, role: ROLE_USER }
I am not sure how to debug this problem!
Plus in development mode i am getting the error
RuntimeException: Failed to write cache file
"/var/www/vhosts/httpdocs/app/cache/dev/classes.php".
So i cant even see if the profiler is indicating any errors!
One common issue is that the app/cache and app/logs directories must be writable both by the web server and the command line user.
http://symfony.com/doc/current/book/installation.html#configuration-and-setup

how to secure whole pages except login page in symfony2?

I want to have whole site secured through login with FOSUserBundle. I tried to set security.yml like this
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
pattern: ^/
form_login:
check_path: /login_check
login_path: /login
provider: fos_userbundle
always_use_default_target_path: true
default_target_path: /dashboard
logout:
path: /logout
target: /
anonymous: ~
#http_basic:
# realm: "Secured Demo Area"
access_control:
- { path: ^/demo/secured/hello/admin/, roles: ROLE_ADMIN }
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
But then I don't know what to set in config.yml
this is my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: ~
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Dashboard\UserBundle\Entity\User
and this is my controller
<?php
namespace Proposals\ProposalsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Proposals\ProposalsBundle\Entity\Proposals;
use Proposals\ProposalsBundle\Form\ProposalsType;
/**
* Proposals controller.
*
*/
class ProposalsController extends Controller
{
/**
* Lists all Proposals entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('ProposalsProposalsBundle:Proposals')->findAll();
return $this->render('ProposalsProposalsBundle:Proposals:index.html.twig', array(
'entities' => $entities,
));
}
When i open any page its not check either user is logged in or not.I want every page is secured through login if user logged in then every page open if user not logged in then page not show or redirect to login.any help appriciated
Every time the same, nobody bats an eye on the documentation. Wayne. But for your spamming you shouldn't get a answer, but this would be unfair ^^
security:
firewalls:
main:
pattern: ^/
# other settings
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: ROLE_USER }
for move to this URL localhost/QuickBacklog/web/app_dev.php/dashboard
you must add like this in the security.yml
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
default_target_path: /dashboard/
logout:
........
invalidate_session: false
anonymous: ~
In the routing file
applicationlogin_success:
pattern: /dashboard/
defaults: { _controller: SampleBundle:Default:FrontPage }
BY USING default_target_path : ROUTING_PATTERN u will redirect it...

Categories