After an authentication module has been assigned to an endpoint, deselecting it and saving doesn't remove it. It just comes back. I have been using a custom auth as well as the session handler. This happens on both.

Thanks.

Comments

tedlchen’s picture

Update: I tried it with a fresh endpoint as well, and it looks like it auto-selects everything.

It looks like function services_edit_form_endpoint_submit() just adds all known modules to the list, which the form picks up later. Instead of using the array keys, it should probably add an enabled field to the array value.

kylebrowning’s picture

How did you turn on an authentication module for Drupal 7? I wasnt aware of any that existed for Drupal 7 yet.

gdd’s picture

You could have turned on sessauth in a previous dev, and then suddenly had it disappear when we removed it. I had thought about writing an update path but chose not to. My bad.

kylebrowning’s picture

Heyrocker can this be closed then or what?

tedlchen’s picture

@heyrocker Ya I notice it sessauth disappeared in a later dev :)

I've been messing around with creating my own auth based on what you guys had left hanging around in the oauth and session modules. I still think this problem will appear when we actually start getting final auths' in there regardless so I wouldn't close it.

BOGUƎ’s picture

StatusFileSize
new1.71 KB

Hmmmm this seems like it's looping through the listed schemes without validating if they're checked or not; plus, it also seems like the empty array is still considered a valid selection.

Line 318:

$auth = array();
  if (isset($form_state['values']['authentication'])) {
    foreach (array_keys($form_state['values']['authentication']) as $module) {
      if (isset($endpoint->authentication[$module])) {
        $auth[$module] = $endpoint->authentication[$module];
      }
      else {
        $auth[$module] = array();
      }
    }
  }
  $endpoint->authentication = $auth;

Here's a patch:

$auth = array();
  if (isset($form_state['values']['authentication'])) {
    foreach (array_keys($form_state['values']['authentication']) as $module) {
      //if module's checkbox is checked (if checked, input value is the module name in the current setup)
      if ( $module == $form_state['input']['authentication'][$module]) {
        if( array_key_exists($module, $endpoint->authentication) ){
          $auth[$module] = $endpoint->authentication[$module];
        }else{
          $auth[$module] = array();
          //if this a new entry, redirect to auth options page
          $form_state['redirect'] = 'admin/config/services/services/' . $endpoint->name . '/authentication';
        }
      }
    }
  }
  $endpoint->authentication = $auth;
kylebrowning’s picture

Status: Active » Needs review
StatusFileSize
new1.69 KB

Updated patch with style cleanup.

kylebrowning’s picture

Status: Needs review » Needs work

IM fixing this to be way better :P stay tuned.

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new5.69 KB

Here we go, try this on for size.

Theres three bugs, one, authentication was always being used if the module was enabled, regardless of if the endpoint enabled it.
Two, the authentication section for each endpoint was always displaying options even if the endpoint didnt have the auth enabled
Three the actual edit page for the endpoint was not properly checking previous endpoint values.

These have all been resolved

this version is 6.x right now ill port to 7.x shortly.

ygerasimov’s picture

There is another problem I have found and fixed in attached patch.

When we add some settings on auth method (for example context in oauth) they get overriden when we edit and save endpoint on its edit form. This happens because ctools execute default method edit_save_form($form_state) of ctools_export_ui class. I have added empty implementation of this method to services_ctools_export_ui class.

Maybe it is reasonable to move our submit function services_ctools_export_ui_form_submit() to edit_save_form() method of the class?

The is also some code style cleaning added.

I have also removed 'Save' button on Authentication form when there is no auth modules enabled.

kylebrowning’s picture

Status: Needs review » Patch (to be ported)

So, this patch was for 6.x, this needs to be ported to 7.x now

kylebrowning’s picture

Status: Patch (to be ported) » Fixed

Ok this is finally fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ilechcod’s picture

I'm not sure if I should be posting this here...
But I cant delete endpoints after creating them.

Is this the way it is supposed to be, or am I missing something?