本文整理汇总了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('');
}
示例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;
}
示例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')]);
}
示例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;
}
示例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]];
}
示例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']]);
}
示例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');
}
示例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();
}
}
示例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();
}
示例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']]);
}
示例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']);
}
示例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);
}
示例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']);
}
示例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], []);
}
示例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], []);
}