8000 Added a DoctrineTokenProvider in Security/Core/Authentication/RememberMe by TerjeBr · Pull Request #6057 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Added a DoctrineTokenProvider in Security/Core/Authentication/RememberMe #6057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Added a DoctrineTokenProvider in Security/Core/Authentication/RememberMe #6057

wants to merge 2 commits into from

Conversation

TerjeBr
Copy link
@TerjeBr TerjeBr commented Nov 18, 2012

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Todo: Add tests and documentation
License of the code: MIT

In the directory Symfony/Component/Security/Core/Authentication/RememberMe there is only one TokenProvider that can be used, and that is the InMemoryTokenProvider.
I think it should be an example DoctrineTokenProvider there as well, that gives an example of how to store the tokens in the database.

@alvarezmario
Copy link
Contributor

@TerjeBr The InMemoryTokenProvider is not an example, is an actual implementation which doesn't rely on external libraries (Doctrine). So I believe your class should be moved to the Doctrine Bridge namespace.

*/
class DoctrineTokenProvider implements TokenProviderInterface
{
private $em;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@stof
Copy link
Member
stof commented Nov 19, 2012

This should indeed be moved to the bridge and should be tested

@TerjeBr
Copy link
Author
TerjeBr commented Nov 19, 2012

This is actually a copy of some code that I am using in my application at work. I just changed the namespace and added some more comments before I made this pull request.

You said it should be moved to the doctrine bridge. If you could tell me the exact directory, I can update my pull request accordingly.

@stof
Copy link
Member
stof commented Nov 19, 2012

@TerjeBr
Copy link
Author
TerjeBr commented Nov 19, 2012

Yes I know, but which sub directory should the file DoctrineTokenProvider.php go into?

@TerjeBr
Copy link
Author
TerjeBr commented Nov 20, 2012

I am finished with this one. (I do not know how to add tests or documentation.)

What happens next? Will this be merged as it is?

@alvarezmario
Copy link
Contributor

@TerjeBr Nope, is not ready yet. If you don't know how to add tests or docs, at least you need to squash your commits into only one.
Then left a final code review and someone take the job of adding the tests and docs. But in the end, I think this will be merged.
You can learn here what is and how to squash your commits: http://symfony.com/doc/current/contributing/code/patches.html#rework-your-patch

fabpot added a commit that referenced this pull request Nov 24, 2012
This PR was merged into the master branch.

Commits
-------

d1b5093 Try to make sure cookies get deleted from the TokenProvider when no longer in use

Discussion
----------

Delete cookies from the TokenProvider that is no longer in use

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Todo: -
License of the code: MIT

When the user logs in, or login fails for some reason, the old "remember me" cookie should be deleted from the TokenProvider if you are using the PersistentTokenBasedRememberMeServices.

As the code is now, the token is only deleted on logout.

---------------------------------------------------------------------------

by TerjeBr at 2012-11-20T13:45:54Z

So, anything else that needs to be done before this is merged?

---------------------------------------------------------------------------

by TerjeBr at 2012-11-21T10:30:53Z

Ok, I have corrected the typo in the comment and squashed the commit.

---------------------------------------------------------------------------

by schmittjoh at 2012-11-21T10:36:29Z

btw, ``canceled`` (more American) and ``cancelled`` (more British) are both
correct English forms.

On Wed, Nov 21, 2012 at 11:30 AM, Terje Bråten <notifications@github.com>wrote:

> Ok, I have corrected the typo in the comment and squashed the commit.
>
> —
> Reply to this email directly or view it on GitHub<#6055 (comment)>.
>
>

---------------------------------------------------------------------------

by schmittjoh at 2012-11-21T10:40:24Z

As a side-note have you verified that this does not break the cookie theft protection?

---------------------------------------------------------------------------

by TerjeBr at 2012-11-21T10:51:10Z

Yes, cookie theft protection is still there and is functioning well.

---------------------------------------------------------------------------

by TerjeBr at 2012-11-21T11:14:04Z

I am using this together with the DoctrineTokenProvider in issue #6057 in my own project and done some extensive testing on it.

---------------------------------------------------------------------------

by TerjeBr at 2012-11-23T10:30:34Z

Is this ready to be merged now?
@TerjeBr
Copy link
Author
TerjeBr commented Nov 24, 2012

Thank you

@TerjeBr
Copy link
Author
TerjeBr commented Dec 1, 2012

Any updates on this?

use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
use Symfony\Component\Security\Core\Exception\TokenNotFoundException;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type as DocType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be renamed to DoctrineType as Doc can have many different meanings.

@fabpot
Copy link
8000
Member
fabpot commented Jan 16, 2013

ping @beberlei

{
/**
* Doctrine DBAL database connection
* Service id: doctrine.dbal.default_connection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should remove this comment. the bridge is not aware of service ids (and you can define several connections which will have different ids)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is meant as an example of where you can find a doctrine connection that is needed in the constructor.
I am sure many programmers will find it useful. Those programmers who already have a doctrine connection from another source they want to use are free to ignore that comment. It is just meant as hint to where you can get one, as I am sure that is the most common problem.

* `lastUsed` datetime NOT NULL,
* `class` varchar(100) NOT NULL,
* `username` varchar(200) NOT NULL
* );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should provide a Schema class for this (as done for the ACL system)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a Schema class? (and what is the ACL system?)
Do you have any URL references where I can read more about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pborreli Just a link to the source code of Schema is very little helpful, when what I obviously need is some kind of introduction to the topic, or some good documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, and where should I put this Schema then?
(What should be the name of the file, and in which directory?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TerjeBr
Copy link
Author
TerjeBr commented Feb 5, 2013

So, any updates on this?

@TerjeBr
Copy link
Author
TerjeBr commented Mar 31, 2013

Ping. What happens next with this?

@fabpot
Copy link
Member
fabpot commented Apr 21, 2013

I've cherry-picked the first commit only as the schema is not really useful as is. Feel free to submit another PR for the schema as done in other places in the framework.

@fabpot fabpot closed this Apr 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0