Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[SecurityBundle] error helper added symfony/symfony#11147#11324

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
i3or1s wants to merge2 commits intosymfony:masterfromi3or1s:master

Conversation

i3or1s
Copy link
Contributor

Added helper that extracts last authentication error and username.

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets[#11147 ]
LicenseMIT
Doc PRsymfony/symfony-docs#3996

@weaverryan
Copy link
Member

Awesome!@i3or1s Can you create a pull request or an issue on the docs to reflect this change (which I'm happy to say will simplify the docs nicely)?

Thanks for the nice PR!

@i3or1s
Copy link
ContributorAuthor

Created related issue in Docssymfony/symfony-docs#3996


/**
* @param bool $clearSession
* @return string
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong. It does not return a string but anAuthenticationException (ornull)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Were you referring tonew AuthenticationException($msg)?

Copy link
Member

Choose a reason for hiding this comment

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

the existing code does not return a string. The request attribute stored inSecurityContextInterface::AUTHENTICATION_ERROR is an AuthenticationException instance, not a string

@weaverryan
Copy link
Member

Issues that stof reported have been fixed.

* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Core\Util;
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 be part ofSymfony\Component\Security\Http instead. Core does not depend on HttpFoundation currently.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Since it is aAuthenticationErrorHelper should it go toSymfony\Component\Security\Http\Authentication?

Copy link
Member

Choose a reason for hiding this comment

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

Sure

@i3or1s
Copy link
ContributorAuthor

Issues are fixed any news on the PR

@fabpot
Copy link
Member

👍

@i3or1s
Copy link
ContributorAuthor

Hi@weaverryan@stof@romainneutron could you check out the PR


/**
* @param bool $clearSession
* @return null|AuthenticationException
Copy link
Member

Choose a reason for hiding this comment

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

I think it's more developer friendly to provide some more documentation comments here.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Any suggestion on what it should be?
"Retrieves last Authentication Error, if $clearSession is true it will also remove the error form session."?

Copy link
Contributor

Choose a reason for hiding this comment

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

"Retrieves last Authentication Error, if $clearSession is true it will also remove the error form session." - this can be read from the code and I don't think we need duplicating it in a comment.

@xabbuh could you explain what kind of a documentation you mean here?

Copy link
Member

Choose a reason for hiding this comment

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

I would write something like this:

/** * Returns the last authentication error. * * Authentication errors are read from the current request or fom the session. Keeping * errors in the session may cause issues when calling the method several times cause * you don't know if the errors has been read before. Therefore, after retrieving the error, * it is erased by default. If you want to keep the error in the session, you'll have to pass * false to this method. */

I know that the method name is quite self-explanatory, but when I look at the generated API documentation I find it useful if there is some more explanation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm against documenting WHAT the code is doing. It's redundant, since you can read what the code is doing from the code itself... Also, this kind of comments often lie, since people tend to forget to update them.

We should rather explain WHY we're doing something, or document potential pitfalls. Anything that's not self-evident from reading the code.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, you can have a look at the code. I just think that this isn't a nice experience from the user's (the developer that uses Symfony) point of view. I feel that the best experience is when one just reads the API documentation and you do know how to use a particular class and which implications its usage has.

Given this method, it's useful to know what theclearSession argument is used for, why I should set it tofalse and what it'll imply if I do that (so maybe my suggestion doesn't fit right how it should be done).

Though I'm not sure if this pull request is the right place to discuss this topic since it's somehow is related to the API documentation as a whole, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

You wouldn't be able to use Symfony's API docs this way, as it hardly contains comments of that kind. You're right it starts going out of the scope for this PR ;)

@xabbuh
Copy link
Member

Shouldn't this also get a changelog entry?

{
$request = $this->getRequest();
$session = $request->getSession();
$msg = 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 rename this local variable. It is not a message

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

$authenticationException what do you think about this one?

Copy link
Member

Choose a reason for hiding this comment

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

much better

Added helper that extracts last authentication error and username.
@i3or1s
Copy link
ContributorAuthor

Issues have been fixed. This is my first contribution so i am eager to see how it all goes. I apologize if i am breaking some rules on this.
Could you point me to the correct direction (document) on what i should do next, if anything, so that PR is merged.

@jakzal
Copy link
Contributor

@i3or1s I think you're done 👍

@weaverryan
Copy link
Member

@i3or1s You're doing great :). You could add a new 2.6.0 CHANGELOG entry to this file:https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

But unless someone sees some other change, we're just waiting for merge (some people are on holiday right now).

Thanks!

@i3or1s
Copy link
ContributorAuthor

@weaverryan Should i change Component CHANGELOG.md since class is added there or Bundle one because it is registered there or maybe both?

@xabbuh
Copy link
Member

You also have to update the version ofsymfony/security in the bundle's composer.json file, don't you?

@stof
Copy link
Member

@i3or1s the class is added in the component, so the changelog entry should be added in the component.

And indeed,@xabbuh is right about bumping the SecurityBundle requirement on the component for people installing the subtree repos

@i3or1s
Copy link
ContributorAuthor

@stof@xabbuh Component is in2.5 is this going to be2.6 so i can change dependency to2.6.
Current one is"symfony/security": "~2.4"

@fabpot
Copy link
Member

@i3or1s Yes, you should change the dep tosymfony/security": "~2.6

@fabpot
Copy link
Member

Thank you@i3or1s.

@fabpot
Copy link
Member

I've fixed the dep in c51f3f3

weaverryan added a commit to symfony/symfony-docs that referenced this pull requestJan 16, 2015
…ls (xabbuh)This PR was merged into the 2.6 branch.Discussion----------[Cookbook][Security] document the new AuthenticationUtils| Q             | A| ------------- | ---| Doc fix?      | no| New docs?     | yes (symfony/symfony#11324)| Applies to    | 2.6+| Fixed tickets |#3996Commits-------dd7c1dd document the new AuthenticationUtils
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@i3or1s@weaverryan@fabpot@xabbuh@jakzal@stof@romainneutron

[8]ページ先頭

©2009-2025 Movatter.jp