Index: services.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/Attic/services.module,v
retrieving revision 1.8.2.88
diff -u -r1.8.2.88 services.module
--- services.module	19 May 2009 02:13:51 -0000	1.8.2.88
+++ services.module	23 May 2009 02:55:44 -0000
@@ -246,8 +246,12 @@
       return call_user_func_array($func, $args);
     }
   }
-  else{
-    return TRUE;
+}
+
+function services_init() {
+  if (variable_get('services_auth_module', '') == '' && user_access('administer services')) {
+    drupal_set_message(t('You do not have any authenciation modules enabled. Your site allows free access to the server.'), 'error'); 
+    drupal_set_message(t('Please enable an authenciation module or visit the !here and confirm this is correct.', array('!here' => l('here', 'admin/build/services/settings'))), 'error');
   }
 }
 
@@ -266,9 +270,6 @@
       return call_user_func_array($func, $args);
     }
   }
-  else{
-    return TRUE;
-  }
 }
 
 /**
@@ -513,4 +514,17 @@
  */
 function services_access_menu() {
   return TRUE;
-} 
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_authentication_info().
+ *
+ * @return array
+ *  The configuration array for the authentication scheme
+ */
+function services_authentication_info() {
+  return array(
+    '#title' => t('No authentication'),
+    '#description' => t('No authenication for clients using the site'),
+  );
+}
\ No newline at end of file
Index: services_admin_browse.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/Attic/services_admin_browse.inc,v
retrieving revision 1.5.2.45
diff -u -r1.5.2.45 services_admin_browse.inc
--- services_admin_browse.inc	20 May 2009 02:05:31 -0000	1.5.2.45
+++ services_admin_browse.inc	23 May 2009 02:55:48 -0000
@@ -344,7 +344,7 @@
     $settings = services_auth_invoke_custom($_POST['auth_module'], 'security_settings');
   }
 
-  if ($settings) {
+  if (is_array($settings)) {
     $cached_form['security']['options']['settings'] = $settings;
   }
   else {
Index: services_admin_keys.inc
===================================================================
RCS file: services_admin_keys.inc
diff -N services_admin_keys.inc
--- services_admin_keys.inc	12 Jan 2009 05:55:05 -0000	1.3.2.15
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,133 +0,0 @@
-<?php
-// $Id: services_admin_keys.inc,v 1.3.2.15 2009/01/12 05:55:05 marcingy Exp $
-/**
- * @author Services Dev Team
- * @file
- *  Generate security keys.
- */
-
-function services_admin_keys_list() {
-  $keys = services_get_keys();
-  $header = array(t('Key'), t('Title'), t('Domain'), array('data' => t('Operations'), 'colspan' => '2'));
-  $rows = array();
-
-  foreach ($keys as $kid => $key) {
-    $row = array();
-
-    $row[] = $kid;
-    $row[] = $key->title;
-    $row[] = $key->domain;
-
-    // Populate the operations field.
-    $operations = array();
-
-    // Set the edit column.
-    $operations[] = array('data' => l(t('edit'), 'admin/build/services/keys/'. $kid));
-
-    // Set the delete column.
-    $operations[] = array('data' => l(t('delete'), 'admin/build/services/keys/'. $kid .'/delete'));
-
-    foreach ($operations as $operation) {
-      $row[] = $operation;
-    }
-    $rows[] = $row;
-  }
-
-  if (empty($rows)) {
-    $rows[] = array(array('data' => t('No API keys created.'), 'colspan' => '5', 'class' => 'message'));
-  }
-
-  return theme('table', $header, $rows);
-}
-
-function services_admin_keys_form() {
-  $kid = arg(4);
-
-  $key = db_fetch_object(db_query("SELECT * FROM {services_keys} WHERE kid = '%s'", $kid));
-
-  $key_kid = isset($key->kid) ? $key->kid : '';
-  $key_title = isset($key->title) ? $key->title : '';
-  $form['kid'] = array(
-    '#type'           => 'hidden',
-    '#default_value'  => $key_kid,
-  );
-
-  if ($key_kid != '') {
-    $form['key'] = array(
-      '#type'           => 'markup',
-      '#title'          => t('Key'),
-      '#value'          => '<strong>'. t('API Key') .':</strong> '. $key_kid,
-    );
-  }
-
-  $form['title'] = array(
-    '#title'          => t('Application title'),
-    '#type'           => 'textfield',
-    '#default_value'  => $key_title,
-    '#description'    => t('The title of the application or website using the service.'),
-  );
-  $form['domain'] = array(
-    '#title'          => t('Allowed domain'),
-    '#type'           => 'textfield',
-    '#default_value'  => isset($key->domain) ? $key->domain : '',
-    '#description'    => t('External domain allowed to use this key.'),
-  );
-
-  $form['submit'] = array(
-    '#type'           => 'submit',
-    '#value'          => $key_title != '' ? t('Save key') : t('Create key'),
-  );
-
-  return $form;
-}
-
-function services_admin_keys_form_submit($form, &$form_state) {
-  services_admin_keys_save($form_state['values']);
-
-  $form_state['redirect']  =  'admin/build/services/keys';
-}
-
-function services_admin_keys_save(&$key) {
-  $is_existing = FALSE;
-  $key['kid'] = !empty($key['kid']) ? $key['kid'] : md5(uniqid(mt_rand(), TRUE));
-  $is_existing =  db_result(db_query("SELECT count(*) FROM {services_keys}
-    WHERE kid = '%s'", $key['kid']));
-
-  if ($is_existing) {
-    db_query("UPDATE {services_keys} SET title = '%s', domain = '%s'
-      WHERE kid = '%s'", $key['title'], $key['domain'], $key['kid']);
-    return SAVED_UPDATED;
-  }
-  else {
-    db_query("INSERT INTO {services_keys} (kid, title, domain)
-      VALUES ('%s', '%s', '%s')", $key['kid'], $key['title'], $key['domain']);
-    return SAVED_NEW;
-  }
-}
-
-function services_admin_keys_delete($kid) {
-  db_query("DELETE FROM {services_keys} WHERE kid = '%s'", $kid);
-}
-
-function services_admin_keys_delete_confirm(&$form_state, $kid = 0) {
-  $key = db_fetch_object(db_query("SELECT * FROM {services_keys} WHERE kid = '%s'", $kid));
-
-  $form['kid'] = array('#type' => 'value', '#value' => $key->kid);
-
-  $message = t('Are you sure you want to delete the key %key?', array('%key' => $key->kid));
-  $caption = '';
-
-  $caption .= '<p>'. t('This action cannot be undone.') .'</p>';
-
-  return confirm_form($form, $message, 'admin/build/services/keys', $caption, t('Delete'));
-}
-
-function services_admin_keys_delete_confirm_submit($form, &$form_state) {
-  services_admin_keys_delete($form_state['values']['kid']);
-
-  $t_args = array('%key' => $form_state['kid']);
-  drupal_set_message(t('The key %key has been deleted.', $t_args));
-  watchdog('menu', 'Deleted key %key.', array('%key' => $t_args), WATCHDOG_NOTICE);
-
-  $form_state['redirect'] = 'admin/build/services/keys';
-}
Index: auth/services_keyauth/services_keyauth.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/auth/services_keyauth/Attic/services_keyauth.inc,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 services_keyauth.inc
--- auth/services_keyauth/services_keyauth.inc	20 May 2009 01:53:12 -0000	1.1.2.6
+++ auth/services_keyauth/services_keyauth.inc	23 May 2009 02:55:51 -0000
@@ -7,12 +7,6 @@
  */
 
 function _services_keyauth_security_settings() {
-  $form['services_use_key'] = array(
-    '#type'           => 'checkbox',
-    '#title'          => t('Use keys'),
-    '#default_value'  => variable_get('services_use_key', TRUE),
-    '#description'    => t('When enabled all method calls need to provide a validation token to autheciate themselves with the server.'),
-  );
   $form['services_key_expiry'] = array(
     '#type'           => 'textfield',
     '#prefix'         => "<div id='services-key-expiry'>",
@@ -97,11 +91,11 @@
         $method['#auth'] = TRUE;
     }
     
-    if ($method['#auth'] and variable_get('services_use_sessid', TRUE)) {
+    if ($method['#auth'] && variable_get('services_use_sessid', TRUE)) {
       array_unshift($method['#args'], $arg_sessid);
     }
 
-    if ($method['#key'] and variable_get('services_use_key', TRUE)) {
+    if ($method['#key']) {
       array_unshift($method['#args'], $arg_nonce);
       array_unshift($method['#args'], $arg_domain_time_stamp);
       array_unshift($method['#args'], $arg_domain_name);
@@ -110,16 +104,7 @@
   }
 }
 
-function _services_keyauth_get_first_key() {
-  $keys = services_keyauth_get_keys();
-  foreach ($keys as $kid => $key) {
-    return $kid;
-  }
-}
-
 function _services_keyauth_alter_browse_form(&$form, $method) {
-  //$timestamp = time();
-  //$nonce = user_password();
 
   foreach ($method['#args'] as $key => $arg) {
     switch ($arg['#name']) {
@@ -153,7 +138,7 @@
 }
 
 function _services_keyauth_authenticate_call($method, $method_name, &$args) {
-  if ($method['#key'] and variable_get('services_use_key', TRUE)) {
+  if ($method['#key']) {
     $hash = array_shift($args);
     $domain = array_shift($args);
     $timestamp = array_shift($args);
@@ -201,10 +186,12 @@
 }
 
 function _services_keyauth_alter_browse_form_submit($method, &$args) {
-  $args_stripped = $args;
-  for ($i = 1; $i <= 4; $i++) {
-    array_shift($args_stripped);
+  if ($method['#key']) {
+    $args_stripped = $args;
+    for ($i = 1; $i <= 4; $i++) {
+      array_shift($args_stripped);
+    }
+    $args[2] = time();
+    $args[0] = services_get_hash($args[2], $args[1], $args[3], $method, $args_stripped);
   }
-  $args[2] = time();
-  $args[0] = services_get_hash($args[2], $args[1], $args[3], $method, $args_stripped);
 }
\ No newline at end of file
Index: auth/services_keyauth/services_keyauth.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/auth/services_keyauth/Attic/services_keyauth.module,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 services_keyauth.module
--- auth/services_keyauth/services_keyauth.module	18 May 2009 20:55:14 -0000	1.1.2.5
+++ auth/services_keyauth/services_keyauth.module	23 May 2009 02:55:52 -0000
@@ -48,8 +48,7 @@
     'title'             => 'Keys',
     'description'       => 'Manage application access to site services.',
     'page callback'     => 'services_keyauth_admin_keys_list',
-    'access callback'   => 'variable_get',
-    'access arguments'  => array('services_use_key', TRUE),
+    'access callback'   => 'services_keyauth_access',
     'type'              => MENU_LOCAL_TASK,
     'file'              => 'services_keyauth.admin.inc',
   );
@@ -71,16 +70,14 @@
   $items['admin/build/services/keys/list'] = array(
     'title'             => 'List',
     'type'              => MENU_DEFAULT_LOCAL_TASK,
-    'access callback'   => 'variable_get',
-    'access arguments'  => array('services_use_key', TRUE),
+    'access callback'   => 'services_keyauth_access',
     'weight'            => -10,
   );
   $items['admin/build/services/keys/add'] = array(
     'title'             => 'Create key',
     'page callback'     => 'drupal_get_form',
     'page arguments'    => array('services_keyauth_admin_keys_form'),
-    'access callback'   => 'variable_get',
-    'access arguments'  => array('services_use_key', TRUE),
+    'access callback'   => 'services_keyauth_access',
     'type'              => MENU_LOCAL_TASK,
     'file'              => 'services_keyauth.admin.inc',
   );
@@ -88,11 +85,9 @@
   return $items;
 }
 
-/*function services_keyauth_validate_key($kid, $timestamp, $domain, $nonce, $method_name, $hash_parameters, $hash) {
-  $hash_parameters = array_merge(array($timestamp, $domain, $nonce, $method_name), $hash_parameters);
-  $rehash = hash_hmac("sha256", implode(';', $hash_parameters), $kid);
-  return ($rehash == $hash) ? TRUE : FALSE;
-}*/
+function services_keyauth_access() {
+  return variable_get('services_auth_module','') == 'services_keyauth' ? TRUE : FALSE;
+}
 
 function services_get_hash($timestamp, $domain, $nonce, $method, $args) {
   $hash_parameters = array($timestamp, $domain, $nonce, $method['#method']);
Index: auth/services_sessauth/services_sessauth.module
===================================================================
RCS file: auth/services_sessauth/services_sessauth.module
diff -N auth/services_sessauth/services_sessauth.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ auth/services_sessauth/services_sessauth.module	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id: $
+/**
+ * @author Services Dev Team
+ * @file
+ *  Provides a key based validation system.
+ */
+
+/**
+ * Implementation of hook_authentication_info().
+ *
+ * @return array
+ *  The configuration array for the authentication scheme
+ */
+function services_sessauth_authentication_info() {
+  return array(
+    '#file' => 'services_sessauth.inc',
+    '#title' => t('Session authentication'),
+    '#description' => t('The default session based authentication'),
+    'alter_methods' => '_services_sessauth_alter_methods',
+    'alter_browse_form' => '_services_sessauth_alter_browse_form',
+    'authenticate_call' => '_services_sessauth_authenticate_call',
+  );
+}
+
+
+function services_sessauth_disable() {
+  cache_clear_all('services:methods', 'cache');
+}
+
+function services_sessauth_enable() {
+  cache_clear_all('services:methods', 'cache');
+}
Index: auth/services_sessauth/services_sessauth.info
===================================================================
RCS file: auth/services_sessauth/services_sessauth.info
diff -N auth/services_sessauth/services_sessauth.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ auth/services_sessauth/services_sessauth.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,6 @@
+; $Id: $
+name = Session Authentication
+description = Provides session authentication for the services module
+package = Services - authentication
+dependencies[] = services
+core = 6.x
Index: auth/services_sessauth/services_sessauth.inc
===================================================================
RCS file: auth/services_sessauth/services_sessauth.inc
diff -N auth/services_sessauth/services_sessauth.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ auth/services_sessauth/services_sessauth.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,59 @@
+<?php
+// $Id: $
+
+/**
+ * @file
+ *  The implementation of the session authentication scheme
+ */
+function _services_sessauth_alter_methods(&$methods) {
+  // Skip this if no services have been activated
+  if (!is_array($methods) || empty($methods)) {
+    return;
+  }
+
+  // sessid arg
+  $arg_sessid = array(
+    '#name' => 'sessid',
+    '#type' => 'string',
+    '#description' => t('A valid sessid.'),
+  );
+
+  foreach ($methods as $key => &$method) {
+    // set method defaults
+    switch ($method['#method']) {
+      case 'system.connect':
+      case 'search.nodes':
+      case 'search.content':
+      case 'search.users':
+        $method['#auth'] = FALSE;
+        break;
+      default:
+        $method['#auth'] = TRUE;
+        array_unshift($method['#args'], $arg_sessid);
+    }
+  }
+}
+
+function _services_sessauth_alter_browse_form(&$form, $method) {
+  if ($method['#auth']) {
+    foreach ($method['#args'] as $key => $arg) {
+      switch ($arg['#name']) {
+        case 'sessid':
+          $form['arg'][$key]['#default_value']  = session_id();
+          break;
+      }
+    }
+  }
+}
+
+function _services_sessauth_authenticate_call($method, $method_name, &$args) {
+  // Add additonal processing for methods requiring session
+  $session_backup = NULL;
+  if ($method['#auth']) {
+    $sessid = array_shift($args);
+    if (empty($sessid)) {
+      return t('Invalid sessid.');
+    }
+    $session_backup = services_session_load($sessid);
+  }
+}
