-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authorize application page now random user, not scope.
- Loading branch information
Showing
10 changed files
with
330 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the authbucket/oauth2-bundle package. | ||
* | ||
* (c) Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\DataFixtures\ORM; | ||
|
||
use AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\Entity\User; | ||
use Doctrine\Common\DataFixtures\FixtureInterface; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
|
||
class UserFixture implements FixtureInterface | ||
{ | ||
public function load(ObjectManager $manager) | ||
{ | ||
$model = new User(); | ||
$model->setUsername('demousername1') | ||
->setPassword('demopassword1') | ||
->setRoles(array( | ||
'ROLE_USER', | ||
)); | ||
$manager->persist($model); | ||
|
||
$model = new User(); | ||
$model->setUsername('demousername2') | ||
->setPassword('demopassword2') | ||
->setRoles(array( | ||
'ROLE_USER', | ||
)); | ||
$manager->persist($model); | ||
|
||
$model = new User(); | ||
$model->setUsername('demousername3') | ||
->setPassword('demopassword3') | ||
->setRoles(array( | ||
'ROLE_USER', | ||
)); | ||
$manager->persist($model); | ||
|
||
$manager->flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the authbucket/oauth2-bundle package. | ||
* | ||
* (c) Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\Entity; | ||
|
||
use AuthBucket\OAuth2\Model\ModelInterface; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
/** | ||
* User | ||
* | ||
* @ORM\Table(name="test_user") | ||
* @ORM\Entity(repositoryClass="AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\Entity\UserRepository") | ||
*/ | ||
class User implements ModelInterface, UserInterface | ||
{ | ||
/** | ||
* @var integer | ||
* | ||
* @ORM\Column(name="id", type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="username", type="string", length=255) | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="password", type="string", length=255) | ||
*/ | ||
protected $password; | ||
|
||
/** | ||
* @var array | ||
* | ||
* @ORM\Column(name="roles", type="array") | ||
*/ | ||
protected $roles; | ||
|
||
/** | ||
* 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; | ||
} | ||
|
||
/** | ||
* Set password | ||
* | ||
* @param string $password | ||
* | ||
* @return User | ||
*/ | ||
public function setPassword($password) | ||
{ | ||
$this->password = $password; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get password | ||
* | ||
* @return string | ||
*/ | ||
public function getPassword() | ||
{ | ||
return $this->password; | ||
} | ||
|
||
/** | ||
* Set roles. | ||
* | ||
* @param array $roles | ||
* | ||
* @return User | ||
*/ | ||
public function setRoles($roles) | ||
{ | ||
$this->roles = $roles; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get roles. | ||
* | ||
* @return array | ||
*/ | ||
public function getRoles() | ||
{ | ||
return $this->roles; | ||
} | ||
|
||
public function getSalt() | ||
{ | ||
} | ||
|
||
public function eraseCredentials() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the authbucket/oauth2-bundle package. | ||
* | ||
* (c) Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\Entity; | ||
|
||
use AuthBucket\OAuth2\Model\ModelManagerInterface; | ||
use Doctrine\ORM\EntityRepository; | ||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
use Symfony\Component\Security\Core\User\UserProviderInterface; | ||
|
||
/** | ||
* UserRepository | ||
* | ||
* This class was generated by the Doctrine ORM. Add your own custom | ||
* repository methods below. | ||
*/ | ||
class UserRepository extends EntityRepository implements ModelManagerInterface, UserProviderInterface | ||
{ | ||
public function getClass() | ||
{ | ||
return $this->getClassName(); | ||
} | ||
|
||
public function createUser() | ||
{ | ||
$class = $this->getClass(); | ||
|
||
return new $class(); | ||
} | ||
|
||
public function deleteUser(UserInterface $user) | ||
{ | ||
$this->getEntityManager()->remove($user); | ||
$this->getEntityManager()->flush(); | ||
} | ||
|
||
public function reloadUser(UserInterface $user) | ||
{ | ||
$this->getEntityManager()->refresh($user); | ||
} | ||
|
||
public function updateUser(UserInterface $user) | ||
{ | ||
$this->getEntityManager()->persist($user); | ||
$this->getEntityManager()->flush(); | ||
} | ||
|
||
public function findUserByUsername($username) | ||
{ | ||
return $this->findOneBy(array( | ||
'username' => $username, | ||
)); | ||
} | ||
|
||
public function loadUserByUsername($username) | ||
{ | ||
$user = $this->findOneBy(array( | ||
'username' => $username, | ||
)); | ||
if ($user === null) { | ||
throw new UsernameNotFoundException(); | ||
} | ||
|
||
return $user; | ||
} | ||
|
||
public function refreshUser(UserInterface $user) | ||
{ | ||
return $this->find($user->getId()); | ||
} | ||
|
||
public function supportsClass($class) | ||
{ | ||
return $this->getEntityName() === $class | ||
|| is_subclass_of($class, $this->getEntityName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.