mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Add BANNED_USERNAMES env var support to RestrictedNames
This commit is contained in:
parent
be75a19260
commit
6cdd64c669
3 changed files with 299 additions and 308 deletions
|
@ -4,7 +4,7 @@ namespace App\Util\Lexer;
|
|||
|
||||
class RestrictedNames
|
||||
{
|
||||
public static $blacklist = [
|
||||
public static $additional = [
|
||||
'autoconfig',
|
||||
'blog',
|
||||
'broadcasthost',
|
||||
|
@ -294,16 +294,18 @@ class RestrictedNames
|
|||
|
||||
public static function get()
|
||||
{
|
||||
$reserved = $blacklist = [];
|
||||
$banned = [];
|
||||
|
||||
if (true == config('pixelfed.restricted_names.use_blacklist')) {
|
||||
$blacklist = self::$blacklist;
|
||||
if(config('instance.username.banned')) {
|
||||
$banned = array_map('trim', explode(',', config('instance.username.banned')));
|
||||
}
|
||||
|
||||
if (true == config('pixelfed.restricted_names.reserved_routes')) {
|
||||
$additional = self::$additional;
|
||||
$reserved = self::$reserved;
|
||||
}
|
||||
|
||||
return array_merge($blacklist, $reserved);
|
||||
$res = array_merge($additional, $reserved, $banned);
|
||||
sort($res);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ return [
|
|||
]
|
||||
],
|
||||
'username' => [
|
||||
'banned' => env('BANNED_USERNAMES'),
|
||||
'remote' => [
|
||||
'formats' => ['@', 'from', 'custom'],
|
||||
'format' => in_array(env('USERNAME_REMOTE_FORMAT', '@'), ['@','from','custom']) ? env('USERNAME_REMOTE_FORMAT', '@') : '@',
|
||||
|
|
|
@ -48,20 +48,6 @@ return [
|
|||
*/
|
||||
'memory_limit' => env('MEMORY_LIMIT', '1024M'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Restricted Usernames
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Optional blacklist to prevent registering usernames that could
|
||||
| be confused for admin or system services.
|
||||
|
|
||||
*/
|
||||
'restricted_names' => [
|
||||
'reserved_routes' => true,
|
||||
'use_blacklist' => env('USERNAME_BLACKLIST', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allow New Registrations
|
||||
|
@ -278,4 +264,6 @@ return [
|
|||
'admin' => [
|
||||
'env_editor' => env('ADMIN_ENV_EDITOR', false)
|
||||
],
|
||||
|
||||
'links_per_post' => env('MAX_LINKS_PER_POST', 0)
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue