当前位置: 首页>>代码示例>>PHP>>正文


PHP Security::salt方法代码示例

本文整理汇总了PHP中Cake\Utility\Security::salt方法的典型用法代码示例。如果您正苦于以下问题:PHP Security::salt方法的具体用法?PHP Security::salt怎么用?PHP Security::salt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Utility\Security的用法示例。


在下文中一共展示了Security::salt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tearDownAfterClass

 /**
  * Purge ConnectionManager configs.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     foreach (self::$datasources as $ds => $configs) {
         \Cake\Datasource\ConnectionManager::drop($ds);
     }
     \Cake\Utility\Security::salt('');
 }
开发者ID:loadsys,项目名称:cakephp-basic-seed,代码行数:12,代码来源:BasicSeedShellTest.php

示例2: beforeDispatch

 /**
  * Callback for Routing.beforeDispatch event.
  *
  * @param \Cake\Event\Event $event The event instance.
  *
  * @return \Cake\Network\Response Response instance.
  */
 public function beforeDispatch(Event $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     $path = urldecode($request->url);
     if (Configure::read('Glide.secureUrls')) {
         SignatureFactory::create(Security::salt())->validateRequest('/' . $path, $request->query);
     }
     $server = ServerFactory::create(Configure::read('Glide.serverConfig'));
     $cache = Configure::read('Glide.cache');
     if ($cache) {
         $timestamp = $server->getSource()->getTimestamp($server->getSourcePath($path));
         $response->modified($timestamp);
         if (!$response->checkNotModified($request)) {
             $response = $server->getImageResponse($path, $request->query);
         }
         $response->cache($timestamp, $cache);
     } else {
         $response = $server->getImageResponse($path, $request->query);
     }
     $headers = Hash::filter((array) Configure::read('Glide.headers'));
     foreach ($headers as $key => $value) {
         $response->header($key, $value);
     }
     return $response;
 }
开发者ID:josegonzalez,项目名称:cakephp-glide,代码行数:33,代码来源:GlideFilter.php

示例3: initialize

 /**
  * Initialize config data and properties.
  *
  * @param array $config The config data.
  * @return void
  */
 public function initialize(array $config)
 {
     if (!$this->_config['cypherKey']) {
         $this->config('cypherKey', Security::salt());
     }
     $this->Cookie->configKey($this->config('cookieName'), ['key' => $this->config('cypherKey'), 'expires' => $this->config('period')]);
 }
开发者ID:narendravaghela,项目名称:cakephp-remember-me,代码行数:13,代码来源:RememberMeComponent.php

示例4: urlBuilder

 /**
  * Get URL builder instance.
  *
  * @return \League\Urls\UrlBuilder URL builder instance.
  */
 public function urlBuilder()
 {
     if (!isset($this->_urlBuilder)) {
         $this->_urlBuilder = UrlBuilderFactory::create(Configure::read('Glide.serverConfig.base_url'), Configure::read('Glide.secureUrls') ? Security::salt() : null);
     }
     return $this->_urlBuilder;
 }
开发者ID:josegonzalez,项目名称:cakephp-glide,代码行数:12,代码来源:GlideHelper.php

示例5: processAuthenticate

 /**
  * Authenticate users based on their JWT. This is inspired by
  * the method _findUser in admads JWT plugin
  *
  * @see https://github.com/ADmad/cakephp-jwt-auth/blob/master/src/Auth/JwtAuthenticate.php
  * @param string $token The token identifier.
  * @param mixed $extra Unused
  * @return array
  */
 public function processAuthenticate($token, $extra = null)
 {
     try {
         $token = JWT::decode($token, Security::salt(), Configure::read('Websockets.allowedAlgs'));
     } catch (Exception $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         return ["FAILURE"];
     }
     if ($token->id == 'server') {
         return ["SUCCESS", ["authid" => $token->id]];
     }
     $fields = Configure::read('Websockets.fields');
     $table = TableRegistry::get(Configure::read('Websockets.userModel'));
     $conditions = [$table->aliasField($fields['id']) => $token->id];
     if (!empty(Configure::read('Websockets.scope'))) {
         $conditions = array_merge($conditions, Configure::read('Websockets.scope'));
     }
     $result = $table->find('all')->where($conditions)->first();
     if (empty($result)) {
         return ["FAILURE"];
     }
     return ["SUCCESS", ["authid" => $result->id]];
 }
开发者ID:gintonicweb,项目名称:websockets,代码行数:34,代码来源:JwtAuthenticationProvider.php

示例6: token

 public function token()
 {
     $user = $this->Auth->identify();
     if (!$user) {
         throw new UnauthorizedException('Invalid username or password');
     }
     $this->set(['success' => true, 'data' => ['token' => $token = \JWT::encode(['id' => $user['id'], 'exp' => time() + 604800], Security::salt())], '_serialize' => ['success', 'data']]);
 }
开发者ID:jeffblack360,项目名称:cake3api,代码行数:8,代码来源:UsersController.php

示例7: setUp

 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Security::salt('12345678901234567890123456789012345678901');
     $this->controller = new Controller(new Request(), new Response());
     $this->controller->loadComponent('Cookie');
     $this->controller->loadComponent('Auth');
 }
开发者ID:edukondaluetg,项目名称:Xeta,代码行数:13,代码来源:LanguageTest.php

示例8: login

 public function login($provider = null)
 {
     if ($provider) {
         $config = ['path' => Router::url(['action' => 'login']) . '/', 'callback_url' => Router::url(['action' => 'callback']), 'security_salt' => Security::salt(), 'Strategy' => Configure::read('OpauthStrategy')];
         $opauth = new \Opauth($config, true);
     } else {
         throw new NotFoundException();
     }
 }
开发者ID:ukatama,项目名称:cakephp3_opauthlogin,代码行数:9,代码来源:OpauthLoginController.php

示例9: token

 public function token()
 {
     $user = $this->Auth->identify();
     if (!$user) {
         throw new UnauthorizedException('Invalid username or password');
     }
     $this->set('data', ['user' => $user, 'token' => $token = \JWT::encode(['id' => $user['id'], 'user' => $user, 'exp' => time() + 604800], Security::salt())]);
     $this->ApiBuilder->execute();
 }
开发者ID:hareshpatel1990,项目名称:cakephp-api,代码行数:9,代码来源:UsersController.php

示例10: google

 public function google()
 {
     $data = $this->request->input('json_decode');
     $user = $this->Users->find('all')->where(['Users.provider' => 'facebook', 'Users.provider_uid' => $data->clientId])->first();
     if (!$user) {
         throw new UnauthorizedException('Invalid username or password');
     }
     $this->Auth->setUser($user);
     $this->set(['success' => true, 'data' => ['token' => JWT::encode(['sub' => $user['id'], 'exp' => time() + 1800], Security::salt()), 'user_id' => $user['id']], '_serialize' => ['success', 'data']]);
 }
开发者ID:shashin62,项目名称:cwed-api,代码行数:10,代码来源:UsersController.php

示例11: createToken

 public function createToken()
 {
     $customer = $this->Customers->find('all', ['fields' => ['id', 'email', 'name', 'password'], 'conditions' => ['email' => $this->request->data('email'), 'gym_id' => $this->request->query('gym_id'), 'deleted' => false, 'is_active' => true]])->first();
     if (!$customer || !(new DefaultPasswordHasher())->check($this->request->data('password'), $customer->password)) {
         throw new UnauthorizedException('Invalid username or password');
     }
     $customer->sub = $customer->id;
     unset($customer->password);
     $this->set(['message' => ['user' => ['name' => $customer->name], 'token' => JWT::encode($customer->toArray(), Security::salt())]]);
     $this->set('_serialize', ['message']);
 }
开发者ID:ast-secret,项目名称:academia-webservice,代码行数:11,代码来源:CustomersController.php

示例12: testInitializeException

 /**
  * Test initialize method
  *
  * @return void
  */
 public function testInitializeException()
 {
     $salt = Security::salt();
     Security::salt('too small');
     try {
         $this->rememberMeComponent = new RememberMeComponent($this->registry, []);
     } catch (InvalidArgumentException $ex) {
         $this->assertEquals('Invalid app salt, app salt must be at least 256 bits (32 bytes) long', $ex->getMessage());
     }
     Security::salt($salt);
 }
开发者ID:OrigamiStructures,项目名称:users,代码行数:16,代码来源:RememberMeComponentTest.php

示例13: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Security::salt('not-the-default');
     DispatcherFactory::add('Routing');
     DispatcherFactory::add('ControllerFactory');
     $this->object = $this->getObjectForTrait('Cake\\Routing\\RequestActionTrait');
     Router::connect('/request_action/:action/*', ['controller' => 'RequestAction']);
     Router::connect('/tests_apps/:action/*', ['controller' => 'TestsApps']);
 }
开发者ID:Slayug,项目名称:castor,代码行数:16,代码来源:RequestActionTraitTest.php

示例14: setUp

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = new Request('posts/index');
     Router::setRequestInfo($this->request);
     $this->response = $this->getMock('Cake\\Network\\Response');
     Security::salt('Xety-Cake3CookieAuth_Xety-Cake3CookieAuth');
     $this->registry = new ComponentRegistry(new Controller($this->request, $this->response));
     $this->registry->load('Cookie');
     $this->registry->load('Auth');
     $this->auth = new CookieAuthenticate($this->registry);
     $password = password_hash('password', PASSWORD_DEFAULT);
     $Users = TableRegistry::get('Users');
     $Users->updateAll(['password' => $password], []);
 }
开发者ID:xety,项目名称:cake3-cookieauth,代码行数:20,代码来源:CookieAuthenticateTest.php

示例15: setUp

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = new Request('posts/index');
     Router::setRequestInfo($this->request);
     $this->response = $this->getMock('Cake\\Network\\Response');
     Security::salt('somerandomhaskeysomerandomhaskey');
     $this->Registry = new ComponentRegistry(new Controller($this->request, $this->response));
     $this->Registry->load('Cookie');
     $this->Registry->load('Auth');
     $this->auth = new CookieAuthenticate($this->Registry, ['fields' => ['username' => 'user_name', 'password' => 'password'], 'userModel' => 'MultiUsers']);
     $password = password_hash('password', PASSWORD_DEFAULT);
     $MultiUsers = TableRegistry::get('MultiUsers');
     $MultiUsers->updateAll(['password' => $password], []);
 }
开发者ID:friendsofcake,项目名称:authenticate,代码行数:20,代码来源:CookieAuthenticateTest.php


注:本文中的Cake\Utility\Security::salt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。