Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [2016-08-04 11:37:17] request.INFO: Matched route "BloggerBlogBundle_security_check". {"route_parameters":{"_route":"BloggerBlogBundle_security_check"},"request_uri":"http://symfony_blog.workspace/web/app_dev.php/login_check"} []
- [2016-08-04 11:37:17] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\BadCredentialsException(code: 0): Bad credentials. at /var/www/workspace/symfony_blog/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php:73, Symfony\Component\Security\Core\Exception\UsernameNotFoundException(code: 0): Username "john.doe" does not exist. at /var/www/workspace/symfony_blog/vendor/symfony/symfony/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php:109)"} []
- [2016-08-04 11:37:17] security.DEBUG: Authentication failure, redirect triggered. {"failure_path":"/login"} []
- [2016-08-04 11:37:17] request.INFO: Matched route "_wdt". {"route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"7677b7","_route":"_wdt"},"request_uri":"http://symfony_blog.workspace/web/app_dev.php/_wdt/7677b7"} []
- Username "john.doe" does not exist.
- security:
- encoders:
- BloggerBlogBundleEntityUser:
- algorithm: sha512
- encode-as-base64: true
- iterations: 10
- providers:
- main:
- entity:
- class: BloggerBlogBundleEntityUser
- property: username
- firewalls:
- main:
- pattern: /.*
- form_login:
- check_path: /login_check
- login_path: /login
- logout: true
- security: true
- anonymous: true
- access_control:
- - { path: /admin/.*, role: ROLE_ADMIN }
- - { path: /.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
- BloggerBlogBundle_comment_create:
- path: /comment/{blog_id}
- defaults: { _controller: 'BloggerBlogBundle:Comment:create' }
- requirements:
- method: POST
- blog_id: d+
- BloggerBlogBundle_security_login:
- path: /login
- defaults: {_controller: BloggerBlogBundle:Security:login }
- BloggerBlogBundle_security_check:
- path: /login_check
- BloggerBlogBundle_security_logout:
- path: /logout
- BloggerBlogBindle_admin_home:
- path: /admin/
- defaults: { controller: BloggerBlogBundle:Admin:index }
- <?php
- // src/Blogger/BlogBundle/Entity/Role.php
- namespace BloggerBlogBundleEntity;
- use SymfonyComponentSecurityCoreRoleRoleInterface;
- use DoctrineORMMapping as ORM;
- /**
- * @ORMEntity
- * @ORMTable(name="role")
- * @ORMHasLifecycleCallbacks
- */
- class Role implements RoleInterface
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(type="string", length=255)
- */
- protected $name;
- /**
- * @ORMColumn(type="datetime", name="created_at")
- */
- protected $createdAt;
- public function __construct()
- {
- $this->setCreatedAt(new DateTime());
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- *
- * @param string $name
- *
- * @return Role
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * Get name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set createdAt
- *
- * @param DateTime $createdAt
- *
- * @return Role
- */
- public function setCreatedAt($createdAt)
- {
- $this->createdAt = $createdAt;
- return $this;
- }
- /**
- * Get createdAt
- *
- * @return DateTime
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
- /**
- * This method is needed to implement RoleInterface
- */
- public function getRole()
- {
- return $this->getName();
- }
- }
- // src/Blogger/BlogBundle/Entity/User.php
- namespace BloggerBlogBundleEntity;
- use DoctrineCommonCollectionArraCollection;
- use DoctrineCommonCollectionsArrayCollection;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMEntity
- * @ORMTable(name="user")
- * @ORMHasLifecycleCallbacks
- */
- class User implements UserInterface
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(type="string", length=255, unique=true)
- */
- protected $username;
- /**
- * @ORMColumn(type="string", length=255)
- */
- protected $password;
- /**
- * @ORMColumn(type="string", length=255)
- */
- protected $salt;
- /**
- * @ORMManyToMany(targetEntity="Role")
- * @ORMJoinTable(name="user_role",
- * joinColumns={@ORMJoinColumn(name="user_id", referencedColumnName="id")},
- * inverseJoinColumns={@ORMJoinColumn(name="role_id", referencedColumnName="id")}
- * )
- */
- protected $userRoles;
- /**
- * @ORMColumn(type="boolean")
- */
- protected $status;
- /**
- * @ORMColumn(name="is_active", type="boolean")
- */
- protected $isActive;
- /**
- * @ORMColumn(type="datetime")
- */
- protected $date_added;
- public function __construct()
- {
- $this->ports = new ArrayCollection();
- $this->userRoles = new ArrayCollection();
- $this->setDateAdded(new DateTime());
- }
- /**
- * Clear user privileges
- **/
- public function eraseCredentials()
- {
- }
- /**
- * @return array of Role object
- */
- public function getRoles()
- {
- return $this->getUserRoles()->toArray();
- }
- /**
- * Compare one user to another user
- * and determine if its same user
- *
- * @param UserInterface $user
- * @return boolean True if equals and false otherwise
- */
- public function equals(UserInterface $user)
- {
- return md5($this->getUsername()) == md5($user->getUsername());
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @return string
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $password;
- }
- /**
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @return string
- */
- public function setSalt($salt)
- {
- $this->salt = $salt;
- return $this;
- }
- /**
- * @return string
- */
- public function getSalt()
- {
- return $this->salt;
- }
- /**
- * Set status
- *
- * @param boolean $status
- *
- * @return User
- */
- public function setStatus($status)
- {
- $this->status = $status;
- return $this;
- }
- /**
- * Get status
- *
- * @return boolean
- */
- public function getStatus()
- {
- return $this->status;
- }
- /**
- * Set dateAdded
- *
- * @param DateTime $dateAdded
- *
- * @return User
- */
- public function setDateAdded($dateAdded)
- {
- $this->date_added = $dateAdded;
- return $this;
- }
- /**
- * Get dateAdded
- *
- * @return DateTime
- */
- public function getDateAdded()
- {
- return $this->date_added;
- }
- /**
- * Get user roles
- *
- * @return ArrayCollection
- */
- public function getUserRoles()
- {
- return $this->userRoles;
- }
- /**
- * Set isActive
- *
- * @param boolean $isActive
- *
- * @return User
- */
- public function setIsActive($isActive)
- {
- $this->isActive = $isActive;
- return $this;
- }
- /**
- * Get isActive
- *
- * @return boolean
- */
- public function getIsActive()
- {
- return $this->isActive;
- }
- /**
- * Add userRole
- *
- * @param BloggerBlogBundleEntityRole $userRole
- *
- * @return User
- */
- public function addUserRole(BloggerBlogBundleEntityRole $userRole)
- {
- $this->userRoles[] = $userRole;
- return $this;
- }
- /**
- * Remove userRole
- *
- * @param BloggerBlogBundleEntityRole $userRole
- */
- public function removeUserRole(BloggerBlogBundleEntityRole $userRole)
- {
- $this->userRoles->removeElement($userRole);
- }
- }
- <?php
- // src/Blogger/BlogBundle/DataFixtures/ORM/UserFixture.php
- namespace BloggerBlogBundleDataFixtureORM;
- use DoctrineCommonDataFixturesFixtureInterface;
- use DoctrineCommonPersistenceObjectManager;
- use BloggerBlogBundleEntityUser;
- use BloggerBlogBundleEntityRole;
- use SymfonyComponentSecurityCoreEncoderMessageDigestPasswordEncoder;
- class UserFixture implements FixtureInterface
- {
- public function load(ObjectManager $manager)
- {
- // Create role
- $role = new Role();
- $role->setName('ROLE_ADMIN');
- $manager->persist($role);
- // Create user
- $user = new User();
- $user->setUsername('john.doe');
- $user->setStatus(true);
- $user->setSalt(md5(time()));
- // encrypt and set password to user
- // this settings coincide to configuration
- $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
- $password = $encoder->encodePassword('admin', $user->getSalt());
- $user->setPassword($password);
- $user->getUserRoles()->add($role);
- $manager->persist($user);
- $manager->flush();
- }
- }
- [2016-08-04 11:37:17] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\BadCredentialsException(code: 0): Bad credentials. at /var/www/workspace/symfony_blog/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php:73, Symfony\Component\Security\Core\Exception\UsernameNotFoundException(code: 0): **Username "john.doe" does not exist. at /var/www/workspace/symfony_blog/vendor/symfony/symfony/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php:109**)"} []
- providers:
- main:
- entity:
- class: BloggerBlogBundle:User
- property: username
- providers:
- main:
- entity: { class: BloggerBlogBundle:User, property: username }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement