Merge pull request #1943 from pixelfed/staging

Add BANNED_USERNAMES env var support to RestrictedNames
This commit is contained in:
daniel 2020-01-16 23:11:49 -07:00 committed by GitHub
commit 77c6962f7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 300 additions and 308 deletions

View file

@ -2,6 +2,7 @@
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.10.7...dev) ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.10.7...dev)
### Added ### Added
- Added ```BANNED_USERNAMES``` .env var, an optional comma separated string to ban specific usernames from being used ([6cdd64c6](https://github.com/pixelfed/pixelfed/commit/6cdd64c6))
### Fixed ### Fixed
- Fixed Story Compose bug affecting postgres instances ([#1918](https://github.com/pixelfed/pixelfed/pull/1918)) - Fixed Story Compose bug affecting postgres instances ([#1918](https://github.com/pixelfed/pixelfed/pull/1918))

View file

@ -4,7 +4,7 @@ namespace App\Util\Lexer;
class RestrictedNames class RestrictedNames
{ {
public static $blacklist = [ public static $additional = [
'autoconfig', 'autoconfig',
'blog', 'blog',
'broadcasthost', 'broadcasthost',
@ -294,16 +294,18 @@ class RestrictedNames
public static function get() public static function get()
{ {
$reserved = $blacklist = []; $banned = [];
if (true == config('pixelfed.restricted_names.use_blacklist')) { if(config('instance.username.banned')) {
$blacklist = self::$blacklist; $banned = array_map('trim', explode(',', config('instance.username.banned')));
} }
if (true == config('pixelfed.restricted_names.reserved_routes')) { $additional = self::$additional;
$reserved = self::$reserved; $reserved = self::$reserved;
}
return array_merge($blacklist, $reserved); $res = array_merge($additional, $reserved, $banned);
sort($res);
return $res;
} }
} }

View file

@ -41,6 +41,7 @@ return [
] ]
], ],
'username' => [ 'username' => [
'banned' => env('BANNED_USERNAMES'),
'remote' => [ 'remote' => [
'formats' => ['@', 'from', 'custom'], 'formats' => ['@', 'from', 'custom'],
'format' => in_array(env('USERNAME_REMOTE_FORMAT', '@'), ['@','from','custom']) ? env('USERNAME_REMOTE_FORMAT', '@') : '@', 'format' => in_array(env('USERNAME_REMOTE_FORMAT', '@'), ['@','from','custom']) ? env('USERNAME_REMOTE_FORMAT', '@') : '@',

View file

@ -48,20 +48,6 @@ return [
*/ */
'memory_limit' => env('MEMORY_LIMIT', '1024M'), '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 | Allow New Registrations
@ -278,4 +264,6 @@ return [
'admin' => [ 'admin' => [
'env_editor' => env('ADMIN_ENV_EDITOR', false) 'env_editor' => env('ADMIN_ENV_EDITOR', false)
], ],
'links_per_post' => env('MAX_LINKS_PER_POST', 0)
]; ];