Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented stateless login for Auth #1169

Merged
merged 1 commit into from Mar 13, 2013
Merged

Conversation

ADmad
Copy link
Member

@ADmad ADmad commented Mar 5, 2013

I think I have finally managed to get stateless auth working in a sensible way with minimal hacking of the AuthComponent.

With this patch when using only BasicAuthenticate there is no redirection to login action nor session starting.

When using Basic and Form authenticators together (order matters) if required http headers are passed and valid user is found it behaves as mentioned above else continues with regular form basic authentication.

For now I only modified existing tests to pass. More tests need to be added after wiser men confirm what I have done is a good idea 馃槃

@@ -97,9 +97,6 @@ class DigestAuthenticate extends BaseAuthenticate {
*/
public function __construct(ComponentCollection $collection, $settings) {
parent::__construct($collection, $settings);
if (empty($this->settings['realm'])) {
$this->settings['realm'] = env('SERVER_NAME');
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure we don't need the realm anymore? I thought it was required to properly generate digest hashes.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is required but now DigestAuthenticate extends BasicAuthenticate and its constructor already sets the realm.

@lorenzo
Copy link
Member

lorenzo commented Mar 6, 2013

This looks good to me, just a bit concerned about the clarity on how unauthenticated() works

@ADmad
Copy link
Member Author

ADmad commented Mar 8, 2013

@markstory @lorenzo Updated docblocks and added new tests. Although session start was prevented when correct credentials were passed for basic/digest auth, I had to add one more tweak to ensure session is not started when no or incorrect credentials are passed (check third commit).

public function testStatelessAuthNoRedirect() {
if (CakeSession::id()) {
session_destroy();
debug(session_id());
Copy link
Member

Choose a reason for hiding this comment

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

Left over debug()

@ADmad
Copy link
Member Author

ADmad commented Mar 13, 2013

Does anyone have anymore feedback on this or should I get the manual updates ready and merge?

@markstory
Copy link
Member

I think it looks good.

lorenzo added a commit that referenced this pull request Mar 13, 2013
Implemented stateless login for Auth
@lorenzo lorenzo merged commit abe6511 into cakephp:2.4 Mar 13, 2013
@lorenzo
Copy link
Member

lorenzo commented Mar 13, 2013

Don't forget to document in the book! :)

@ADmad
Copy link
Member Author

ADmad commented Mar 13, 2013

I thought my previous message would be hint enough that I intend to. :)

@lorenzo
Copy link
Member

lorenzo commented Mar 13, 2013

I was not enough :trollface:

@ADmad ADmad deleted the 2.4-auth-take-2 branch March 14, 2013 21:53
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.

None yet

3 participants