Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. security:
  2. encoders:
  3. administrators:
  4. class: NasivinAdminBundleEntityAdmin
  5. algorithm: plaintext
  6.  
  7. role_hierarchy:
  8. ROLE_USER: ROLE_USER
  9. ROLE_ADMIN: ROLE_ADMIN
  10. ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
  11.  
  12. providers:
  13. administrators:
  14. entity: { class: NasivinAdminBundle:Admin, property: username }
  15.  
  16. firewalls:
  17. dev:
  18. pattern: ^/(_(profiler|wdt)|css|images|js)/
  19. security: false
  20.  
  21. admin:
  22. pattern: ^/admin/
  23. provider: administrators
  24. anonymous: ~
  25. form_login:
  26. check_path: _admin_security_check
  27. login_path: _admin_login
  28. default_target_path: /admin/bla
  29. always_use_default_target_path: true
  30. logout:
  31. path: _admin_logout
  32. target: /admin
  33.  
  34. access_control:
  35. #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
  36. admin_login:
  37. path: ^/admin/login
  38. roles: IS_AUTHENTICATED_ANONYMOUSLY
  39. admin_area:
  40. path: ^/admin/.*
  41. roles: ROLE_USER
  42.  
  43. <?php
  44. /**
  45. * Created by PhpStorm.
  46. * User: Michal
  47. * Date: 16.9.2014
  48. * Time: 11:37
  49. */
  50.  
  51. namespace NasivinAdminBundleEntity;
  52.  
  53.  
  54. use SymfonyComponentSecurityCoreUserUserInterface;
  55. use DoctrineORMMapping as ORM;
  56.  
  57. /**
  58. * NasivinAdminBundleEntityAdmin
  59. *
  60. * @ORMTable(name="tb_admin")
  61. * @ORMEntity()
  62. */
  63. class Admin implements UserInterface
  64. {
  65. /**
  66. * @ORMColumn(name="id", type="integer")
  67. * @ORMId
  68. * @ORMGeneratedValue(strategy="AUTO")
  69. */
  70. protected $id;
  71.  
  72. /**
  73. * @ORMColumn(name="username", type="string", length=25, unique=true)
  74. */
  75. protected $username;
  76.  
  77. /**
  78. * @ORMColumn(name="password", type="string", length=64)
  79. */
  80. protected $password;
  81.  
  82. /**
  83. * @ORMColumn(name="salt", type="string", length=64)
  84. */
  85. protected $salt;
  86.  
  87. /**
  88. * @inheritDoc
  89. */
  90. public function getUsername()
  91. {
  92. return $this->username;
  93. }
  94.  
  95. /**
  96. * @inheritDoc
  97. */
  98. public function getSalt()
  99. {
  100. // you *may* need a real salt depending on your encoder
  101. // see section on salt below
  102. return null;
  103. }
  104.  
  105. /**
  106. * @inheritDoc
  107. */
  108. public function getPassword()
  109. {
  110. return $this->password;
  111. }
  112.  
  113. /**
  114. * @inheritDoc
  115. */
  116. public function eraseCredentials()
  117. {
  118. }
  119.  
  120. /**
  121. * @inheritDoc
  122. */
  123. public function getRoles()
  124. {
  125. return array("ROLE_ADMIN", "ROLE_USER");
  126. }
  127.  
  128. /**
  129. * Get id
  130. *
  131. * @return integer
  132. */
  133. public function getId()
  134. {
  135. return $this->id;
  136. }
  137.  
  138. /**
  139. * Set username
  140. *
  141. * @param string $username
  142. * @return Admin
  143. */
  144. public function setUsername($username)
  145. {
  146. $this->username = $username;
  147.  
  148. return $this;
  149. }
  150.  
  151. /**
  152. * Set password
  153. *
  154. * @param string $password
  155. * @return Admin
  156. */
  157. public function setPassword($password)
  158. {
  159. $this->password = $password;
  160.  
  161. return $this;
  162. }
  163.  
  164. /**
  165. * Set salt
  166. *
  167. * @param string $salt
  168. * @return Admin
  169. */
  170. public function setSalt($salt)
  171. {
  172. $this->salt = $salt;
  173.  
  174. return $this;
  175. }
  176. }
  177.  
  178. {% extends "::base.html.twig" %}
  179.  
  180. {% block title %}NasivinAdminBundle:Security:login{% endblock %}
  181.  
  182. {% block body %}
  183. <h1>Welcome to the Security:login page</h1>
  184. <form action="{{ path('_admin_security_check') }}" method="post">
  185. <label for="username">Username:</label>
  186. <input type="text" id="username" name="_username" />
  187.  
  188. <label for="password">Password:</label>
  189. <input type="password" id="password" name="_password" />
  190.  
  191. {#
  192. If you want to control the URL the user
  193. is redirected to on success (more details below)
  194. <input type="hidden" name="_target_path" value="/account" />
  195. #}
  196.  
  197. <button type="submit">login</button>
  198. </form>
  199. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement