Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
20b4cf7b
Commit
20b4cf7b
authored
Jan 24, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added key generation task.
parent
70dd657e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
dependencies.php
laravel/cli/dependencies.php
+10
-0
key.php
laravel/cli/tasks/key.php
+53
-0
core.php
laravel/core.php
+1
-0
No files found.
laravel/cli/dependencies.php
View file @
20b4cf7b
...
...
@@ -25,6 +25,16 @@ IoC::register('task: bundle', function()
return
new
Tasks\Bundle\Bundler
;
});
/**
* The key task is responsible for generating a secure, random
* key for use by the application when encrypting strings or
* setting the hash values on cookie signatures.
*/
IoC
::
singleton
(
'task: key'
,
function
()
{
return
new
Tasks\Key
;
});
/**
* The bundle repository is responsible for communicating with
* the Laravel bundle sources to get information regarding any
...
...
laravel/cli/tasks/key.php
0 → 100644
View file @
20b4cf7b
<?php
namespace
Laravel\CLI\Tasks
;
use
Laravel\Str
;
use
Laravel\File
;
class
Key
extends
Task
{
/**
* The path to the application config.
*
* @var string
*/
protected
$path
;
/**
* Create a new instance of the Key task.
*
* @return void
*/
public
function
__construct
()
{
$this
->
path
=
APP_PATH
.
'config/application'
.
EXT
;
}
/**
* Generate a random key for the application.
*
* @param array $arguments
* @return void
*/
public
function
generate
(
$arguments
=
array
())
{
// By default the Crypter class uses AES-256 encryption which uses
// a 32 byte input vector, so that is the length of string we will
// generate for the application token unless another length is
// specified through the CLI.
$key
=
Str
::
random
(
array_get
(
$arguments
,
0
,
32
));
$config
=
str_replace
(
"'key' => '',"
,
"'key' => '
{
$key
}
',"
,
File
::
get
(
$this
->
path
),
$count
);
File
::
put
(
$this
->
path
,
$config
);
if
(
$count
>
0
)
{
echo
"Configuration updated with secure key!"
;
}
else
{
echo
"An application key already exists!"
;
}
}
}
\ No newline at end of file
laravel/core.php
View file @
20b4cf7b
...
...
@@ -91,6 +91,7 @@ Autoloader::$mappings = array(
'Laravel\\CLI\\Tasks\\Migrate\\Migrator'
=>
SYS_PATH
.
'cli/tasks/migrate/migrator'
.
EXT
,
'Laravel\\CLI\\Tasks\\Migrate\\Resolver'
=>
SYS_PATH
.
'cli/tasks/migrate/resolver'
.
EXT
,
'Laravel\\CLI\\Tasks\\Migrate\\Database'
=>
SYS_PATH
.
'cli/tasks/migrate/database'
.
EXT
,
'Laravel\\CLI\\Tasks\\Key'
=>
SYS_PATH
.
'cli/tasks/key'
.
EXT
,
'Laravel\\Database\\Connection'
=>
SYS_PATH
.
'database/connection'
.
EXT
,
'Laravel\\Database\\Expression'
=>
SYS_PATH
.
'database/expression'
.
EXT
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment