Download & Extend

Decouple api and user authentication

Project:Services
Version:6.x-3.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

Currently if you want to use user authenciation you need to enable the keys authenication which is just plan wrong. These should be seperate options and now we have the new api we can do this easily.

Comments

#1

Status:active» needs review

This patch splits the authenication and session methods out.

* A new module is provided
* Option to use keys is removed it is now turned if key auth is enabled
* Option to use sess id is removed it is now turned on if session auth is enabled
* Fixes an issue where by if you have no security setting things break
*

AttachmentSizeStatusTest resultOperations
split-auth.patch10.99 KBIgnored: Check issue status.NoneNone

#2

Assigned to:Anonymous» Hugo Wetterberg

Great job with this one, the split into two separate modules makes sense. The session authentication module is actually the only one I think that it makes sense to include with services out of the box.

Will review this afternoon.

#3

Ok, this didn't really work.

I fixed showstopper issues with inconsistent handling of the #key and #auth method attributes. See: http://github.com/hugowetterberg/services/commit/e8cded3b5b08888d81a49f7...

I also found and fixed a bug in the services_auth_invoke* methods. This bug caused authentication to fail when no auth module was selected. Not caused by your patch, but I thought that I could include it here. See: http://github.com/hugowetterberg/services/commit/4dbcdf6fe16548e69cbfd1c...

Cheers
/Hugo

AttachmentSizeStatusTest resultOperations
split-auth_3.patch12.66 KBIgnored: Check issue status.NoneNone

#4

I'll review it latter just wanted to comment on This bug caused authentication to fail when no auth module was selected.

This feature was added after discussion with Heyrocker simply to prevent people opening their sites up by having no modules installed or authenication set up, which appeared to be a security hole. Maybe the answer is have a 3rd auth method - open access which does this but ensures that people have actively selected this approach - I don't think the module needs to do anything except put a warning on the config screen.

#5

One other thought should the code related to access arguments be moved into sessauth as it is only valid if we have a user to check against?

#6

Hmm, I think I disagree on this point. People who activate the services module and service-implementation modules have made a very active choice to open up their site. No security was bypassed, as a session with the required privileges still is required to access services, so I wouldn't call it a security hole. No authentication equals cookie based session authentication.

And then that's another problem with this patch: that it, combined with the decision to disable services until a authentication method is selected, closes the door on those depending on the previously valid option of using "browser-based cookies".

#7

Ah, no! OAuth, for example, loads the user that authorized the access token. Clients using the key_authentication method might still want to use sessions. Hmm, that's right, I think that we have to add session support back in in the key_authentication method. I'm all for having a separate sessions-only auth method, but clients using the key_authentication method must still be able to maintain sessions without resorting to cookies.

#8

Ah so basically we remove the option to use keys from keyauth(as it is now) and add back an optional session handling feature. Even still though it doesn't make sense that the access check is always being carried out given that an access check might not be required - ie I have a key and am not using sessions. One option is for key_auth or what ever auth method is being used to check and see if sessions are being used if they aren't unset ['#access'] on a method - key_auth now has controls on methods at a key level.

#9

The access check must always be performed, for security reasons.

#10

Good pont - updating tickets while having my mind on work at the same time is never a good idea.

So all we need to do is allow for sessions on the key auth ;)

#11

Status:needs review» needs work

#12

New version of the patch

* Sessions can now be enabled on keyauth
* Keys are none selectable
* Failure if no authenication method is selected have been removed and replaced with a prompt to take action
* Introduction a no authenication method that sits in the core service module - if it is selected prompt above goes.
* Tweak to ensure the browser doesn't error in certain cases with key auth (system.connect)

AttachmentSizeStatusTest resultOperations
split-auth.patch15.68 KBIgnored: Check issue status.NoneNone

#13

Status:needs work» needs review

Sorry forgot to change status

#14

Status:needs review» needs work

I finally got a chance to do some review on this

1) When applying the patch to the current -dev I got the following:

The next patch would delete the file services_admin_keys.inc,
which does not exist!  Assume -R? [n]

I told it no and did not apply anyways.

2) When key authentication is enabled, the settings page still has a checkbox for "Use Sessid". This should be removed.

3) It also appears that the variable 'services_use_sessid' is still being used. If I enable key auth and check the 'use sessid' box, it still requires both key api and sessid, and gives the missing required parameter error if both are not present. Do we even need the 'services_use_sessid' and 'services_use_key' variables anymore?

4) It would be really nice if, when upgrading from a new version, we could have an update_n() hook that automatically checks which auth method they were using (sessions or keys) and enables the appropriate module. This would make the upgrade path a lot easier and avoid the kind of issues we've seen in the queue recently where people are taken by surprise at having to enable a new module. Is this possible? I'm not completely sure.

That's what I've got from giving it a spin, haven't looked at the actual code yet.

#15

Status:needs work» needs review

New version of the patch

* Fixes an issue when no auth is selected that authenciation fails
* Removes the file that shouldn't be in the patch
* Keeps the ability to have no security at all but maintains a warning of you do it
* Leaves in option to use sessions and keys as per discussions with Hugo
* Adds an update hook to try and work out which module to enable and what to set the authenication variable too

AttachmentSizeStatusTest resultOperations
split-auth.patch12.23 KBIgnored: Check issue status.NoneNone

#16

This version does all the above plus it makes domain a required field under keys - this is the identifier to the server so it needs to be required.

AttachmentSizeStatusTest resultOperations
split-auth.patch12.98 KBIgnored: Check issue status.NoneNone

#17

Reroll after the security release. I have committed some bug fixes so this patch only does what it needs too rather than other things.

Needs to be reviewed.

AttachmentSizeStatusTest resultOperations
split-auth.patch8.75 KBIgnored: Check issue status.NoneNone

#18

Title:Decouple api and user authenciation» Decouple api and user authentication

I'd like to see this modified such that if you have no authentication method chosen, then all requests to Services return Access Denied, regardless of the menu system. Intuitively it makes the most sense - if I have not chosen an authentication method, then things should in fact not get authenticated. It is also the safest course of action, and will prevent people from accidentally opening their sites up. For instance, say a bug crops up in the uprgade code which doesn't properly transfer a person's choice of key authentication to their new installation. Instead no authentication module is chosen, but their permission settings are still the same. They are now totally open. We should be handling this defensively rather than just assuming nothing will go wrong. It is the safest route and 100% guaranteed to keep the security team happy.

In the situation where someone has not chosen an authentication method we shouldn't have a drupal_set_message() on every page either. Instead I'd like to see this rolled into hook_requirements so you only get the warning on install and on the status page.

Also, if we're going to continue to allow sessions in key authentication, then why have a separate session authentication at all? If unchecking both is going to open up the server as before, why have a no authentication option at all? This whole situation as the patch is now, where there are multiple paths to the same result, many of which are not clearly labeled as such, is really confusing.

More thoughts anyone?

#19

Assigned to:Hugo Wetterberg» Anonymous

Maybe we mark this as postponed and concentrate on other things?

One thing that we should do is create an upgrade path that enables keyauth if required?

If we agree on this I'll look to review the crud patch and start work on the http://drupal.org/node/314739.

#20

Status:needs review» postponed

After discussions with heyrocker postponed

#21

Version:6.x-1.x-dev» 6.x-3.x-dev
Status:postponed» active

So the plan as far as I know is that session auth stays in for 3.x, and API key auth is going to contrib. Marcingy has agreed to maintain. I am going to take a look at the original patches from this issue as a starting point for that, I don't think the api for pluggable auth has changed much in the new branch.

#22

The issue is that given that keyauth as it stand supports session and key combos then I'm thinking that we simply say if you want key based auth you need to move to oauth otherwise we end up with key auth that ends up effectively handling session auth and keyauth to support existing configurations. In otherwords we kill keyauth.

#23

Status:active» closed (won't fix)

I do believe keyauth is dead in 3.x so I will be closing this issue. If anything thats in this thread needs to be moved somewhere, it should be moved to this discssuion #610698: Refactor the Services module

nobody click here