SHARE
TWEET

Untitled

a guest Aug 13th, 2016 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. security:
  2. providers:
  3.     my_ldap:
  4.         ldap:
  5.             service: ldap
  6.             base_dn: ou=People,dc=insa-toulouse,dc=fr
  7.             search_dn: ~
  8.             search_password: ~
  9.             default_roles: ROLE_USER
  10.             uid_key: uid
  11.  
  12. firewalls:
  13.     dev:
  14.         pattern: ^/(_(profiler|wdt)|css|images|js)/
  15.         security: false
  16.  
  17.     login_firewall:
  18.         pattern:   ^/login$
  19.         anonymous: ~
  20.     main:
  21.         logout:
  22.             path: /logout
  23.         form_login_ldap:
  24.             login_path: login
  25.             check_path: login_check
  26.             service: ldap
  27.             dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
  28.         #anonymous: true
  29.         #http_basic_ldap:
  30.         #    service: ldap
  31.         #    dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
  32.     default:
  33.         anonymous: ~
  34.    
  35. services:
  36. ldap:  
  37.     class: SymfonyComponentLdapLdapClient
  38.     arguments:
  39.         - srv-ldap
  40.    
  41. <?php
  42.  
  43.     namespace ClubInfoPizzaBundleController;
  44.  
  45.     use SymfonyBundleFrameworkBundleControllerController;
  46.     use SymfonyComponentHttpFoundationRequest;
  47.     use SensioBundleFrameworkExtraBundleConfigurationRoute;
  48.  
  49.     class SecurityController extends Controller
  50.     {
  51.             /**
  52.              * @Route("/login", name="login")
  53.              */
  54.             public function loginAction(Request $request)
  55.             {
  56.                     $authenticationUtils = $this->get('security.authentication_utils');
  57.  
  58.                     // get the login error if there is one
  59.                     $error = $authenticationUtils->getLastAuthenticationError();
  60.  
  61.                     // last username entered by the user
  62.                     $lastUsername = $authenticationUtils->getLastUsername();
  63.  
  64.                     return $this->render(
  65.                             'ClubInfoPizzaBundle:security:login.html.twig',
  66.                             array(
  67.                                     // last username entered by the user
  68.                                     'last_username' => $lastUsername,
  69.                                     'error'         => $error,
  70.                             )
  71.                     );
  72.             }
  73.     }
  74.    
  75. {% if error %}
  76.     <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
  77. {% endif %}
  78.  
  79. <form action="{{ path('login') }}" method="post">
  80.     <label for="username">Username:</label>
  81.     <input type="text" id="username" name="_username" value="{{ last_username }}" />
  82.  
  83.     <label for="password">Password:</label>
  84.     <input type="password" id="password" name="_password" />
  85.  
  86.     {#
  87.         If you want to control the URL the user
  88.         is redirected to on success (more details below)
  89.         <input type="hidden" name="_target_path" value="/account" />
  90.     #}
  91.  
  92.     <button type="submit">login</button>
  93. </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top