daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jul 17th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Authorization' => [
  2.     (int) 0 => 'Digest username="land.com", realm="test", nonce="random", uri="/users/mlogin", qop=auth, nc=, cnonce="", response="52cca0984c1c9e4547d1e01d9ef2a22e", opaque="nochange"'
  3. ],
  4.    
  5. <?php
  6.     namespace AppController;
  7.  
  8.     use CakeControllerController;
  9.     use CakeEventEvent;
  10.  
  11.     class AppController extends Controller
  12.     {
  13.  
  14.         public function initialize()
  15.         {
  16.             parent::initialize();
  17.  
  18.             $this->loadComponent('RequestHandler', [
  19.                 'enableBeforeRedirect' => false,
  20.             ]);
  21.             $this->loadComponent('Flash');
  22.  
  23.             $this->loadComponent('Auth', [
  24.                 'authenticate' => [
  25.                     'Digest' => [
  26.                         'fields' => ['username' => 'username', 'password' => 'digest_hash'],
  27.                         'userModel' => 'Users',
  28.  
  29.                         'realm' => 'test',
  30.                         'nonce' => 'nonce',
  31.                         // 'qop' => 'auth',
  32.                         'opaque' => 'nochange',
  33.  
  34.                     ],
  35.                 ],
  36.                 'storage' => 'Memory',
  37.                 'unauthorizedRedirect' => false
  38.             ]);
  39.  
  40.  
  41.         }
  42.  
  43.  
  44.     }
  45.    
  46. <?php
  47.  
  48.     namespace AppModelTable;
  49.  
  50.     use CakeAuthDigestAuthenticate;
  51.     use CakeEventEvent;
  52.     use CakeORMTable;
  53.  
  54.     class UsersTable extends Table
  55.     {
  56.         public function beforeSave(Event $event)
  57.         {
  58.             $entity = $event->getData('entity');
  59.  
  60.             // Make a password for digest auth.
  61.             $entity->digest_hash = DigestAuthenticate::password(
  62.                 $entity->username,
  63.                 $entity->plain_password,
  64.                 'test'
  65.             );
  66.             return true;
  67.         }
  68.     }
  69.  
  70.     ?>
  71.    
  72. <?php
  73.     namespace AppController;
  74.     use AppControllerAppController;
  75.     use CakeControllerController;
  76.     use CakeEventEvent;
  77.  
  78.     class UsersController extends AppController
  79.     {
  80.  
  81.  
  82.         function beforeFilter(Event $event) {
  83.             parent::beforeFilter($event);
  84.             $this->Auth->allow( );
  85.         }
  86.  
  87.         public function mlogin() {
  88.  
  89.             debug( $this->request->getHeaders() );
  90.             $user = $this->Auth->identify();
  91.             debug( $user );
  92.  
  93.         }
  94.  
  95.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top