├── .gitignore
├── ext_tables.sql
├── Resources
├── Public
│ └── Icons
│ │ └── Extension.png
└── Private
│ └── Templates
│ └── Restricted.html
├── Configuration
├── Services.yaml
├── TCA
│ └── Overrides
│ │ └── be_users.php
└── RequestMiddlewares.php
├── .php_cs
├── ext_emconf.php
├── composer.json
├── Classes
├── Middleware
│ ├── BackendRedirect.php
│ ├── BackendUserCheck.php
│ └── RequestCheck.php
└── Configuration
│ └── ConfigBuilder.php
├── CHANGELOG.rst
├── .ddev
└── config.yaml
├── README.rst
└── LICENSE.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | /.Build
2 | /composer.lock
3 |
--------------------------------------------------------------------------------
/ext_tables.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE be_users
2 | (
3 | tx_restrictfe_clearbesession tinyint(4) DEFAULT '0' NOT NULL,
4 | );
--------------------------------------------------------------------------------
/Resources/Public/Icons/Extension.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sourcebroker/restrictfe/HEAD/Resources/Public/Icons/Extension.png
--------------------------------------------------------------------------------
/Configuration/Services.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | _defaults:
3 | autowire: true
4 | autoconfigure: true
5 | public: false
6 |
7 | SourceBroker\Restrictfe\:
8 | resource: '../Classes/*'
--------------------------------------------------------------------------------
/.php_cs:
--------------------------------------------------------------------------------
1 | exclude('vendor')
5 | ->in(__DIR__);
6 |
7 | return PhpCsFixer\Config::create()
8 | ->setRules(array(
9 | '@PSR2' => true,
10 | ))
11 | ->setFinder($finder);
12 |
--------------------------------------------------------------------------------
/Configuration/TCA/Overrides/be_users.php:
--------------------------------------------------------------------------------
1 | [
7 | 'exclude' => 1,
8 | 'label' => 'Clear BE session after login',
9 | 'config' => [
10 | 'type' => 'check',
11 | 'default' => 0,
12 | ],
13 | ],
14 | ];
15 |
16 | ExtensionManagementUtility::addTCAcolumns('be_users', $tempColumns);
17 | ExtensionManagementUtility::addToAllTCAtypes('be_users',
18 | '--div--;Restrictfe,tx_restrictfe_clearbesession');
19 |
--------------------------------------------------------------------------------
/Resources/Private/Templates/Restricted.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | Please login first to see this website / Bitte melden Sie sich an um diese Seite sehen zu können.
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | [EN] Please login first to see this website.
15 | [DE] Bitte melden Sie sich an um diese Seite sehen zu können.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ext_emconf.php:
--------------------------------------------------------------------------------
1 | 'Restrict access for staging and prod instances',
5 | 'description' => 'This extension blocks access to frontend and allows to show it only to some defined exception\'s like if the request is from an authorized backend user, has specific IP, header, domain, language or GET/POST vars. Useful to protect your staging and production instances.',
6 | 'author' => 'Inscript Team',
7 | 'author_email' => 'office@inscript.dev',
8 | 'author_company' => 'Inscript',
9 | 'category' => 'fe',
10 | 'version' => '12.0.1',
11 | 'state' => 'stable',
12 | 'constraints' => [
13 | 'depends' => [
14 | 'typo3' => '11.5.0-13.4.999',
15 | ],
16 | 'conflicts' => [],
17 | 'suggests' => [],
18 | ],
19 | ];
20 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sourcebroker/restrictfe",
3 | "license": [
4 | "GPL-2.0-or-later"
5 | ],
6 | "type": "typo3-cms-extension",
7 | "description": "This extension blocks access to frontend and allows to show it only to some defined exception's like if the request is from an authorized backend user, has specific IP, header, domain, language or GET/POST vars. Useful to protect your staging and production instances.",
8 | "require": {
9 | "php": ">=7.4",
10 | "typo3/cms-core": "^11 || ^12 || ^13",
11 | "typo3/cms-fluid": "^11 || ^12 || ^13",
12 | "ext-json": "*"
13 | },
14 | "autoload": {
15 | "psr-4": {
16 | "SourceBroker\\Restrictfe\\": "Classes/"
17 | }
18 | },
19 | "authors": [
20 | {
21 | "name": "Krystian Szymukowicz",
22 | "email": "k.szymukowicz@gmail.com"
23 | }
24 | ],
25 | "replace": {
26 | "typo3-ter/restrictfe": "self.version"
27 | },
28 | "config": {
29 | "vendor-dir": ".Build/vendor",
30 | "bin-dir": ".Build/bin",
31 | "allow-plugins": {
32 | "typo3/class-alias-loader": true,
33 | "typo3/cms-composer-installers": true
34 | }
35 | },
36 | "extra": {
37 | "typo3/cms": {
38 | "web-dir": ".Build/Web",
39 | "extension-key": "restrictfe"
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Configuration/RequestMiddlewares.php:
--------------------------------------------------------------------------------
1 | [
5 | 'sourcebroker/restrictfe/backend-user-check' => [
6 | 'target' => \SourceBroker\Restrictfe\Middleware\BackendUserCheck::class,
7 | 'after' => [
8 | 'typo3/cms-frontend/backend-user-authentication',
9 | ],
10 | 'before' => [
11 | 'typo3/cms-frontend/authentication',
12 | ]
13 | ],
14 | 'sourcebroker/restrictfe/request-check' => [
15 | 'target' => \SourceBroker\Restrictfe\Middleware\RequestCheck::class,
16 | 'before' => [
17 | 'staticfilecache/fallback',
18 | 'typo3/cms-frontend/timetracker',
19 | ],
20 | ],
21 | ],
22 | 'backend' => [
23 | 'sourcebroker/restrictfe/backend-user-check' => [
24 | 'target' => \SourceBroker\Restrictfe\Middleware\BackendUserCheck::class,
25 | 'after' => [
26 | 'typo3/cms-backend/authentication',
27 | ],
28 | 'before' => [
29 | 'typo3/cms-backend/output-compression',
30 | ]
31 | ],
32 | 'sourcebroker/restrictfe/redirect-backend' => [
33 | 'target' => \SourceBroker\Restrictfe\Middleware\BackendRedirect::class,
34 | 'after' => [
35 | 'typo3/cms-backend/authentication',
36 | ],
37 | 'before' => [
38 | 'typo3/cms-backend/output-compression',
39 | ],
40 | ],
41 | ],
42 | ];
43 |
--------------------------------------------------------------------------------
/Classes/Middleware/BackendRedirect.php:
--------------------------------------------------------------------------------
1 | context = $context;
23 | }
24 |
25 | /**
26 | * @param ServerRequestInterface $request
27 | * @param RequestHandlerInterface $handler
28 | * @return ResponseInterface
29 | * @throws AspectNotFoundException
30 | */
31 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
32 | {
33 | if ($this->context->getAspect('backend.user')->isLoggedIn()) {
34 | $cookieParams = $request->getCookieParams();
35 | if(isset($cookieParams['tx_restrictfe_redirect'])) {
36 | setcookie('tx_restrictfe_redirect', '', -1, '/');
37 | $returnUrl = GeneralUtility::sanitizeLocalUrl($cookieParams['tx_restrictfe_redirect']);
38 | if($returnUrl) {
39 | return new RedirectResponse($returnUrl);
40 | }
41 | }
42 | }
43 | return $handler->handle($request);
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Classes/Middleware/BackendUserCheck.php:
--------------------------------------------------------------------------------
1 | configBuilder = $configBuilder;
27 | $this->config = $this->configBuilder->get();
28 | }
29 |
30 | /**
31 | * Creates a backend user authentication object, tries to authenticate a user
32 | *
33 | * @param ServerRequestInterface $request
34 | * @param RequestHandlerInterface $handler
35 | * @return ResponseInterface
36 | */
37 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
38 | {
39 | $backendUser = $GLOBALS['BE_USER'];
40 | $cookieParams = $request->getCookieParams();
41 | if (!empty($backendUser->user)
42 | && !empty($backendUser->user['uid'])
43 | && !isset($cookieParams['tx_restrictfe'])) {
44 | $cookieValue = (string)GeneralUtility::md5int(
45 | substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], random_int(1, 5), random_int(5, 10)) . time()
46 | );
47 | GeneralUtility::makeInstance(Registry::class)->set('tx_restrictfe', $cookieValue, true);
48 | setcookie(
49 | 'tx_restrictfe',
50 | $cookieValue,
51 | $this->config['cookie']['expire'],
52 | $this->config['cookie']['path'],
53 | $this->config['cookie']['domain'],
54 | $this->config['cookie']['secure'],
55 | $this->config['cookie']['httponly']
56 | );
57 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['beLogged'] = true;
58 |
59 | // TODO: so far code below does not set cookie
60 |
61 | // $cookie = new Cookie(
62 | // 'tx_restrictfe',
63 | // $cookieValue,
64 | // $this->config['cookie']['expire'],
65 | // $this->config['cookie']['path'],
66 | // $this->config['cookie']['domain'],
67 | // $this->config['cookie']['secure'],
68 | // );
69 | // $response = $handler->handle($request);
70 | // return $response->withAddedHeader('set-cookie', $cookie->__toString());
71 | }
72 | if (!empty($backendUser->user['tx_restrictfe_clearbesession'])) {
73 | $backendUser->removeCookie($backendUser::getCookieName());
74 | }
75 | return $handler->handle($request);
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/Classes/Configuration/ConfigBuilder.php:
--------------------------------------------------------------------------------
1 | 'EXT:restrictfe/Resources/Private/Templates/Restricted.html',
45 | 'cookie' => [
46 | 'expire' => time() + 86400 * 30,
47 | 'path' => '/',
48 | 'domain' => '',
49 | 'secure' => GeneralUtility::getIndpEnv('TYPO3_SSL'),
50 | 'httponly' => true,
51 | ],
52 | 'exceptions' => [
53 | 'ip' => ['127.0.0.1', '192.168.0.0/16', '172.16.0.0/12', '10.0.0.0/8'],
54 | 'backendUser' => true,
55 | ],
56 | ];
57 |
58 | // Merge external config with default conifg
59 | if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe'])) {
60 | if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exeptions']) || !empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exception'])) {
61 | throw new RuntimeException('You have typo in config name. You set "exeptions" or "exception" instead of "exceptions". ' . json_encode($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe'], JSON_THROW_ON_ERROR));
62 | }
63 | ArrayUtility::mergeRecursiveWithOverrule(
64 | $config,
65 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']
66 | );
67 | }
68 |
69 | if (isset($config['enable'])) {
70 | throw new RuntimeException('Extension restrictfe: The $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'restrictfe\'][\'enable\'] is deprecated. Read docs on https://github.com/sourcebroker/restrictfe');
71 | }
72 | return $config;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | Changelog
2 | ---------
3 |
4 | 12.0.1
5 | ------
6 |
7 | a) [BUGFIX] Make reading GET and POST compatible with TYPO3 v13
8 |
9 | 12.0.0
10 | ------
11 |
12 | a) [BUGFIX] Fix "clear BE session" functionality to allow BE accounts to authenticate only and then be clear
13 | to see staging instance content without access to BE.
14 |
15 | b) [TASK][BREAKING] Move RequestCheck before'typo3/cms-frontend/timetracker' and especially 'staticfilecache/fallback'
16 | to show protecting screen before staticfilecache returns it from cache. Remove standaloneView because edge case
17 | problems to use it at early stage. Remove "sysLanguageUid" condition as sysLanguageUid is not available at
18 | so early stage yet. Language condition must be done by part of uri condition now.
19 |
20 | c) [TASK] Bring back support for PHP 7.4 as TYPO3 11 can still use PHP 7.4.
21 |
22 | 11.1.0
23 | ~~~~~~
24 |
25 | a) [TASK] Increase support to TYPO3 13
26 |
27 | 11.0.0
28 | ~~~~~~
29 |
30 | a) [TASK][BREAKING] Drop support for TYPO3 10. Increase PHP req to 8+.
31 |
32 | 10.1.0
33 | ~~~~~~
34 |
35 | a) [TASK] Increase support to TYPO3 12
36 |
37 | 10.0.4
38 | ~~~~~~
39 |
40 | a) [BUGFIX] Check if array value exist before reading.
41 |
42 | 10.0.3
43 | ~~~~~~
44 |
45 | a) [BUGFIX] Drop reading of settings BE/cookieSecure and SYS/cookieHttpOnly that does no longer exist in TYPO3 10 and 11.
46 |
47 | 10.0.2
48 | ~~~~~~
49 |
50 | a) [BUGFIX] Add all private network IP addresses as allowed to see website. (ddev on local issue)
51 | b) [TASK] Update composer.json allowed plugins.
52 |
53 | 10.0.1
54 | ~~~~~~
55 |
56 | a) [BUGFIX] Fix wrong value as parameter of setcookie method.
57 |
58 | 10.0.0
59 | ~~~~~~
60 |
61 | a) [TASK] Increase support to TYPO3 11 and drop support for TYPO3 8 and 9.
62 | b) [BUGFIX] Add "extension-key" for TYPO3.
63 | c) [TASK] Add ddev.
64 | d) [TASK] Add backend redirect to front after authorisation.
65 | e) [TASK] Refactor legacy code.
66 |
67 | 9.0.0
68 | ~~~~~
69 |
70 | a) [TASK] Increase TYPO3 to 10 / drop support for 6.2 and 7.6
71 | b) [TASK] Change location of ext icon.
72 | c) [TASK] Refactor code.
73 |
74 | 8.2.1
75 | ~~~~~
76 |
77 | a) [BUGFIX] Fix headers are case-insensitive.
78 | b) [TASK] Extend supported TYPO3 verison in ext_emconf.php
79 |
80 | 8.2.0
81 | ~~~~~
82 |
83 | a) [TASK] Change required TYPO3 from 'typo3/cms' to 'typo3/cms-core'.
84 | b) [FEATURE] Add compatibility for TYPO3 9.0.0
85 | c) [DOCS] Docs improvements.
86 | d) [TASK] Change icon.
87 |
88 | 8.1.0
89 | ~~~~~
90 |
91 | a) [FEATURE] Use TYPO3 settings for cookie HttpOnly and Secure flags.
92 |
93 |
94 | 8.0.3
95 | ~~~~~
96 |
97 | a) [BUGFIX] Set restrictfe cookie only for backend user authorisation.
98 |
99 |
100 | 8.0.2
101 | ~~~~~
102 |
103 | a) [TASK] Add more info to composer.json
104 |
105 | b) [TASK] Add some badges to README.rst
106 |
107 | c) [TASK] Add styleci / php_cs / scrutinizer configs
108 |
109 | d) [BUGFIX] array_unique($conditionResults) cannot be passed to reset() as the parameter $array expects a reference.
110 |
111 | e) [BUGFIX] The parameter $_params and $pObj is not used and could be removed.
112 |
113 | f) [BUGFIX] Make strict comparision of values.
114 |
115 | g) [TASK] Change exit() with die()
116 |
117 | h) [DOCS] Mods for docs.
118 |
119 | 8.0.1
120 | ~~~~~
121 |
122 | a) [DOCS] Docs update.
123 |
124 | b) [BUGFIX] Bring back 'ip' => '127.0.0.1' as default config.
125 |
126 | c) [CLENAUP] Remove not used use.
127 |
128 | 8.0.0
129 | ~~~~~
130 |
131 | a) [BUGFIX] Store BE_USER just after authorization because later in typo3/sysext/frontend/Classes/Http/RequestHandler.php
132 | BE_USER can be unset if he has no access to page tree, but we do not care about acceess to page tree for restrictfe.
133 | We only want to know if user logged sucessfully.
134 |
135 | b) [CLEANUP] PSR-2 formatting.
136 |
137 | c) [DOCS] Divide changlog from main README.rst into separate CHANGELOG.rst.
138 |
139 | d) [BUGFIX] Disable php inspecion for $_params in restrictFrontend($_params, &$pObj) - PhpUnusedParameterInspection.
140 |
141 | e) [TASK] Cleanup up on detecting for wrong naming for "exeptions" or "exception".
142 |
143 | f) [TASK][BREAKING] Move config to external class and remove hook to set additional config params as all params can be
144 | overwritten by config from $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']
145 |
146 | g) [TASK] Add separate class which hooks into BE login process and stores tx_restrictfe cookie after sucessful BE
147 | login. Additionally logout user if "tx_restrictfe_clearbesession" is set for user profile.
148 |
149 | 7.1.2
150 | ~~~~~
151 |
152 | a) Update ext_emconf.php.
153 |
154 | 7.1.1
155 | ~~~~~
156 |
157 | a) Documentation update.
158 |
159 | 7.1.0
160 | ~~~~~
161 |
162 | a) Add "requestUri" condition and update documentation for "requestUri" usage.
163 | a) Update documentation with info that restrictfe is diabled for local instances.
164 |
165 |
166 | 7.0.1
167 | ~~~~~
168 |
169 | a) Update documentation with default settings.
170 |
171 | 7.0.0
172 | ~~~~~
173 |
174 | a) Remove "enable" $GLOBALS['TYPO3\_CONF\_VARS']['EXTCONF']['restrictfe']['enable']
175 | b) Set 127.0.0.1 as default IP that is allowed to see frontend without authorization.
176 |
--------------------------------------------------------------------------------
/.ddev/config.yaml:
--------------------------------------------------------------------------------
1 | name: restrictfe
2 | type: php
3 | docroot: ""
4 | php_version: "8.2"
5 | webserver_type: nginx-fpm
6 | router_http_port: "80"
7 | router_https_port: "443"
8 | xdebug_enabled: false
9 | additional_hostnames: []
10 | additional_fqdns: []
11 | database:
12 | type: mariadb
13 | version: "10.2"
14 | use_dns_when_possible: true
15 | composer_version: ""
16 | web_environment: []
17 | corepack_enable: false
18 |
19 | # Key features of DDEV's config.yaml:
20 |
21 | # name: # Name of the project, automatically provides
22 | # http://projectname.ddev.site and https://projectname.ddev.site
23 |
24 | # type: # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
25 | # See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
26 | # information on the different project types
27 | # "drupal" covers recent Drupal 8+
28 |
29 | # docroot: # Relative path to the directory containing index.php.
30 |
31 | # php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"
32 |
33 | # You can explicitly specify the webimage but this
34 | # is not recommended, as the images are often closely tied to DDEV's' behavior,
35 | # so this can break upgrades.
36 |
37 | # webimage: # nginx/php docker image.
38 |
39 | # database:
40 | # type: # mysql, mariadb, postgres
41 | # version: # database version, like "10.11" or "8.0"
42 | # MariaDB versions can be 5.5-10.8, 10.11, and 11.4.
43 | # MySQL versions can be 5.5-8.0.
44 | # PostgreSQL versions can be 9-16.
45 |
46 | # router_http_port: # Port to be used for http (defaults to global configuration, usually 80)
47 | # router_https_port: # Port for https (defaults to global configuration, usually 443)
48 |
49 | # xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart"
50 | # Note that for most people the commands
51 | # "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better,
52 | # as leaving Xdebug enabled all the time is a big performance hit.
53 |
54 | # xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart"
55 | # Note that for most people the commands
56 | # "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
57 | # as leaving Xhprof enabled all the time is a big performance hit.
58 |
59 | # webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
60 |
61 | # timezone: Europe/Berlin
62 | # This is the timezone used in the containers and by PHP;
63 | # it can be set to any valid timezone,
64 | # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
65 | # For example Europe/Dublin or MST7MDT
66 |
67 | # composer_root:
68 | # Relative path to the Composer root directory from the project root. This is
69 | # the directory which contains the composer.json and where all Composer related
70 | # commands are executed.
71 |
72 | # composer_version: "2"
73 | # You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
74 | # to use the latest major version available at the time your container is built.
75 | # It is also possible to use each other Composer version channel. This includes:
76 | # - 2.2 (latest Composer LTS version)
77 | # - stable
78 | # - preview
79 | # - snapshot
80 | # Alternatively, an explicit Composer version may be specified, for example "2.2.18".
81 | # To reinstall Composer after the image was built, run "ddev debug refresh".
82 |
83 | # nodejs_version: "20"
84 | # change from the default system Node.js version to any other version.
85 | # See https://ddev.readthedocs.io/en/stable/users/configuration/config/#nodejs_version for more information
86 | # and https://www.npmjs.com/package/n#specifying-nodejs-versions for the full documentation,
87 | # Note that using of 'ddev nvm' is discouraged because "nodejs_version" is much easier to use,
88 | # can specify any version, and is more robust than using 'nvm'.
89 |
90 | # corepack_enable: false
91 | # Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm
92 |
93 | # additional_hostnames:
94 | # - somename
95 | # - someothername
96 | # would provide http and https URLs for "somename.ddev.site"
97 | # and "someothername.ddev.site".
98 |
99 | # additional_fqdns:
100 | # - example.com
101 | # - sub1.example.com
102 | # would provide http and https URLs for "example.com" and "sub1.example.com"
103 | # Please take care with this because it can cause great confusion.
104 |
105 | # upload_dirs: "custom/upload/dir"
106 | #
107 | # upload_dirs:
108 | # - custom/upload/dir
109 | # - ../private
110 | #
111 | # would set the destination paths for ddev import-files to /custom/upload/dir
112 | # When Mutagen is enabled this path is bind-mounted so that all the files
113 | # in the upload_dirs don't have to be synced into Mutagen.
114 |
115 | # disable_upload_dirs_warning: false
116 | # If true, turns off the normal warning that says
117 | # "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"
118 |
119 | # ddev_version_constraint: ""
120 | # Example:
121 | # ddev_version_constraint: ">= 1.22.4"
122 | # This will enforce that the running ddev version is within this constraint.
123 | # See https://github.com/Masterminds/semver#checking-version-constraints for
124 | # supported constraint formats
125 |
126 | # working_dir:
127 | # web: /var/www/html
128 | # db: /home
129 | # would set the default working directory for the web and db services.
130 | # These values specify the destination directory for ddev ssh and the
131 | # directory in which commands passed into ddev exec are run.
132 |
133 | # omit_containers: [db, ddev-ssh-agent]
134 | # Currently only these containers are supported. Some containers can also be
135 | # omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
136 | # the "db" container, several standard features of DDEV that access the
137 | # database container will be unusable. In the global configuration it is also
138 | # possible to omit ddev-router, but not here.
139 |
140 | # performance_mode: "global"
141 | # DDEV offers performance optimization strategies to improve the filesystem
142 | # performance depending on your host system. Should be configured globally.
143 | #
144 | # If set, will override the global config. Possible values are:
145 | # - "global": uses the value from the global config.
146 | # - "none": disables performance optimization for this project.
147 | # - "mutagen": enables Mutagen for this project.
148 | # - "nfs": enables NFS for this project.
149 | #
150 | # See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
151 | # See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen
152 |
153 | # fail_on_hook_fail: False
154 | # Decide whether 'ddev start' should be interrupted by a failing hook
155 |
156 | # host_https_port: "59002"
157 | # The host port binding for https can be explicitly specified. It is
158 | # dynamic unless otherwise specified.
159 | # This is not used by most people, most people use the *router* instead
160 | # of the localhost port.
161 |
162 | # host_webserver_port: "59001"
163 | # The host port binding for the ddev-webserver can be explicitly specified. It is
164 | # dynamic unless otherwise specified.
165 | # This is not used by most people, most people use the *router* instead
166 | # of the localhost port.
167 |
168 | # host_db_port: "59002"
169 | # The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
170 | # unless explicitly specified.
171 |
172 | # mailpit_http_port: "8025"
173 | # mailpit_https_port: "8026"
174 | # The Mailpit ports can be changed from the default 8025 and 8026
175 |
176 | # host_mailpit_port: "8025"
177 | # The mailpit port is not normally bound on the host at all, instead being routed
178 | # through ddev-router, but it can be bound directly to localhost if specified here.
179 |
180 | # webimage_extra_packages: [php7.4-tidy, php-bcmath]
181 | # Extra Debian packages that are needed in the webimage can be added here
182 |
183 | # dbimage_extra_packages: [telnet,netcat]
184 | # Extra Debian packages that are needed in the dbimage can be added here
185 |
186 | # use_dns_when_possible: true
187 | # If the host has internet access and the domain configured can
188 | # successfully be looked up, DNS will be used for hostname resolution
189 | # instead of editing /etc/hosts
190 | # Defaults to true
191 |
192 | # project_tld: ddev.site
193 | # The top-level domain used for project URLs
194 | # The default "ddev.site" allows DNS lookup via a wildcard
195 | # If you prefer you can change this to "ddev.local" to preserve
196 | # pre-v1.9 behavior.
197 |
198 | # ngrok_args: --basic-auth username:pass1234
199 | # Provide extra flags to the "ngrok http" command, see
200 | # https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h"
201 |
202 | # disable_settings_management: false
203 | # If true, DDEV will not create CMS-specific settings files like
204 | # Drupal's settings.php/settings.ddev.php or TYPO3's additional.php
205 | # In this case the user must provide all such settings.
206 |
207 | # You can inject environment variables into the web container with:
208 | # web_environment:
209 | # - SOMEENV=somevalue
210 | # - SOMEOTHERENV=someothervalue
211 |
212 | # no_project_mount: false
213 | # (Experimental) If true, DDEV will not mount the project into the web container;
214 | # the user is responsible for mounting it manually or via a script.
215 | # This is to enable experimentation with alternate file mounting strategies.
216 | # For advanced users only!
217 |
218 | # bind_all_interfaces: false
219 | # If true, host ports will be bound on all network interfaces,
220 | # not the localhost interface only. This means that ports
221 | # will be available on the local network if the host firewall
222 | # allows it.
223 |
224 | # default_container_timeout: 120
225 | # The default time that DDEV waits for all containers to become ready can be increased from
226 | # the default 120. This helps in importing huge databases, for example.
227 |
228 | #web_extra_exposed_ports:
229 | #- name: nodejs
230 | # container_port: 3000
231 | # http_port: 2999
232 | # https_port: 3000
233 | #- name: something
234 | # container_port: 4000
235 | # https_port: 4000
236 | # http_port: 3999
237 | # Allows a set of extra ports to be exposed via ddev-router
238 | # Fill in all three fields even if you don’t intend to use the https_port!
239 | # If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start.
240 | #
241 | # The port behavior on the ddev-webserver must be arranged separately, for example
242 | # using web_extra_daemons.
243 | # For example, with a web app on port 3000 inside the container, this config would
244 | # expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998
245 | # web_extra_exposed_ports:
246 | # - name: myapp
247 | # container_port: 3000
248 | # http_port: 9998
249 | # https_port: 9999
250 |
251 | #web_extra_daemons:
252 | #- name: "http-1"
253 | # command: "/var/www/html/node_modules/.bin/http-server -p 3000"
254 | # directory: /var/www/html
255 | #- name: "http-2"
256 | # command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
257 | # directory: /var/www/html
258 |
259 | # override_config: false
260 | # By default, config.*.yaml files are *merged* into the configuration
261 | # But this means that some things can't be overridden
262 | # For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
263 | # and you can't erase existing hooks or all environment variables.
264 | # However, with "override_config: true" in a particular config.*.yaml file,
265 | # 'use_dns_when_possible: false' can override the existing values, and
266 | # hooks:
267 | # post-start: []
268 | # or
269 | # web_environment: []
270 | # or
271 | # additional_hostnames: []
272 | # can have their intended affect. 'override_config' affects only behavior of the
273 | # config.*.yaml file it exists in.
274 |
275 | # Many DDEV commands can be extended to run tasks before or after the
276 | # DDEV command is executed, for example "post-start", "post-import-db",
277 | # "pre-composer", "post-composer"
278 | # See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
279 | # information on the commands that can be extended and the tasks you can define
280 | # for them. Example:
281 | #hooks:
282 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | TYPO3 Extension ``restrictfe``
2 | ==============================
3 |
4 | .. image:: https://poser.pugx.org/sourcebroker/restrictfe/d/monthly
5 | :target: https://packagist.org/packages/sourcebroker/restrictfe
6 |
7 | .. image:: https://poser.pugx.org/sourcebroker/restrictfe/v/stable
8 | :target: https://packagist.org/packages/sourcebroker/restrictfe
9 |
10 | .. image:: https://poser.pugx.org/sourcebroker/restrictfe/license
11 | :target: https://packagist.org/packages/sourcebroker/restrictfe
12 |
13 |
14 | .. contents:: :local:
15 |
16 | What does it do?
17 | ----------------
18 |
19 | This extension blocks access to frontend and allows to show it
20 | only to some defined exception's like if the request is from
21 | an authorized backend user, has specific IP, header, domain, language
22 | or GET/POST vars. Useful to protect your staging and production instances.
23 |
24 | How this can be useful for me?
25 | ------------------------------
26 |
27 | It will be useful whenever you want to protect whole or part of website
28 | from being public. See following examples for staging and production
29 | instances.
30 |
31 | **For staging instances**
32 |
33 | You will find restrictfe useful if you have staging instances and you want to
34 | protect frontend content form public but at the same time:
35 |
36 | - allow to show frontend to authorized backend users,
37 | - allow to show frontend to IP of your VPN,
38 | - allow to show frontend to your external spiders for crawling,
39 | - allow some payment systems to send confirm link to your application endpoint,
40 | - allow Google Page Speed to make tests,
41 | - etc.
42 |
43 | **For production instances**
44 |
45 | You will find restrictfe useful if you have production instance which is
46 | already live but access to some part of website must be yet hidden for
47 | regular frontend users. At the same time is must be accessible in
48 | frontend for logged backend users which must be able to edit content on
49 | that hidden part.
50 |
51 | Installation
52 | ------------
53 |
54 | Just use composer or download by Extension Manager.
55 |
56 | ::
57 |
58 | composer require sourcebroker/restrictfe
59 |
60 | Be aware that after installation restrictfe blocks all traffic to
61 | frontend by default. This is by design because if you will add new
62 | staging instances they will be blocked by default so there is no risk
63 | that you forgot to protect it and someone will see new staging instance
64 | or google will index it. Of course you must remember to unblock
65 | production instance with simple line:
66 |
67 | ::
68 |
69 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = ['*' => true];
70 |
71 | Put this config in the file that is included only on live instance!
72 |
73 | **Notice!**
74 | restrictfe protection is not working if $_SERVER['REMOTE_ADDR'] == 127.0.0.1 so if you
75 | are working on your local instance restrictfe is disabled. If you want to to make testing
76 | and enable it on your local instance insert following line in typo3conf/AdditionalConfiguration.php
77 | or in some extension ext_localconf.php:
78 | ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions']['ip'] = '__UNSET';``
79 |
80 |
81 | Documentation
82 | -------------
83 |
84 | Exceptions
85 | ~~~~~~~~~~
86 |
87 | As stated earlier restrictfe blocks all traffic to frontend and we must
88 | set exceptions that will allow to see the frontend. Those exceptions
89 | conditions are written in
90 | ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions']``
91 | array. By default on first level conditions are joined with logical OR
92 | but you can join them with AND if you will make AND array key and
93 | conditions inside. You can nest OR/AND conditions inside arrays. Values
94 | of conditions can be string or array. If its array its OR'ed. Some
95 | conditions can be negated. In such case the conditions inside are
96 | AND'ed.
97 |
98 | **The result of this condition checks is used to decide if frontend
99 | should be blocked or not. If its true then frontend is not blocked.**
100 |
101 | Conditions
102 | ~~~~~~~~~~
103 |
104 | backendUser
105 | +++++++++++
106 |
107 | - | *Argument*
108 | | Activate (boolean)
109 |
110 | - *Note*
111 |
112 | - If activated then frontend will be visible to authorized backend
113 | users. Only single authorization is needed and user can log out
114 | because special cookie will allow him to see frontend. That also
115 | means that BE user can unlog from backend and still see the
116 | frontend - its crucial for good testing of caching bugs.
117 |
118 | - For backend user you can check “Clear BE session after login” in
119 | backend user record. This will unlog BE user from backend just
120 | after authorization. This is useful if you want to create only
121 | kind of "preview" BE user. This user does not need to have access
122 | to any BE module and do not needs rights to read/write any table.
123 |
124 | - As stated in last points after backend user authorization special
125 | cookie is set that allows to access frontend even after backend
126 | user will be logged off. You can set each aspect of this cookie by
127 | setting ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['cookie']``
128 | array. For example you can set the cookie for multiple subdomains
129 | which means that user needs to authorize only once to have access
130 | to all protected subdomains. With htaccess password user would
131 | need to authorize to each subdomain independently. Example:
132 | ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['cookie']['domain'] = '.example.com';``
133 |
134 | - *Example*
135 |
136 | ::
137 |
138 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
139 | backendUser' => true
140 | ];
141 |
142 | domain
143 | ++++++
144 |
145 | - | *Argument*
146 | | Domain name (string)
147 |
148 | - | *Note*
149 | | You can negate this condition with !domain.
150 |
151 | - | *Example*
152 | | Allow frontend access to all except traffic to domain sub.example.com
153 |
154 | ::
155 |
156 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
157 | '!domain' => ['sub.example.com']
158 | ];
159 |
160 | get
161 | +++
162 |
163 | - | *Argument*
164 | | "getName=getValue" pairs (string)
165 |
166 | - | *Note*
167 | | You can negate this condition with !get.
168 |
169 | - | *Example*
170 | | Allow only request with GET param secret=999 to access frontend.
171 |
172 | ::
173 |
174 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
175 | 'get' => 'secret=999'
176 | ];
177 |
178 | header
179 | ++++++
180 |
181 | - | *Argument*
182 | | "headerName=headerValue" pairs (string)
183 |
184 | - | *Note*
185 | | You can negate this condition with !header.
186 |
187 | - | *Example*
188 | | Allow only request with HTTP header MYHEADER=99 to access frontend.
189 |
190 | ::
191 |
192 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
193 | 'header' => 'MYHEADER=99'
194 | ];
195 |
196 | ip
197 | ++
198 |
199 | - | *Argument*
200 | | Single IP with mask (string), comma separated list of IPs with
201 | mask(string), array of IPs with mask (array string)
202 |
203 | - | *Note*
204 | | In the background a ``GeneralUtility::cmpIP()`` is used so you can
205 | use \* and mask for IP like 12.12.45.\* or 13.55.0.0/16.
206 | | You can negate this condition with !ip.
207 |
208 | - | *Example*
209 | | Allow frontend access only for IP 11.11.11.11 or 22.22.22.22 or 33.33.33.33
210 |
211 | ::
212 |
213 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
214 | 'ip' => [
215 | '11.11.11.11', // ip of developers VPN
216 | '22.22.22.22' // ip of client VPN
217 | '33.33.33.33' // payment system confirm request
218 | ]
219 | ];
220 |
221 |
222 | Block frontend access to traffic from IP range 34.34.0.0/16
223 |
224 | ::
225 |
226 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
227 | '!ip' => [
228 | '34.34.0.0/16', // some not trusted network
229 | ]
230 | ];
231 |
232 | post
233 | ++++
234 |
235 | - | *Argument*
236 | | "getName=getValue" pairs (string)
237 |
238 | - | *Note*
239 | | You can negate this condition with !post.
240 |
241 | - | *Example*
242 | | Allow only request with POST param secret=999 to access frontend.
243 |
244 | ::
245 |
246 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
247 | 'post' => 'secret=999'
248 | ];
249 |
250 | requestUri
251 | ++++++++++
252 |
253 | - | *Argument*
254 | | uri part after domain without leading slash (string)
255 |
256 | - | *Note*
257 | | You can negate this condition with !requestUri. The argument is search for only on begining of text.
258 |
259 | - | *Example*
260 | | Allow only request starting with api/ to be processed.
261 |
262 | ::
263 |
264 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
265 | 'requestUri' => ['api/', 'api2/']
266 | ];
267 |
268 |
269 |
270 | Configuration examples
271 | ----------------------
272 |
273 | Some most useful real live configuration examples:
274 |
275 | Production instance that must have language /fr/ not available public
276 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277 |
278 | ::
279 |
280 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
281 | '!requestUri' => 'fr/',
282 | ];
283 |
284 | Production instance that must have domain "sub.example.com" not avaliable public
285 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286 |
287 | ::
288 |
289 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
290 | '!domain' => 'sub.example.com',
291 | ];
292 |
293 | Staging instance that needs to unblock frontend for Google Page Speed Insights
294 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295 |
296 | ::
297 |
298 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
299 | 'get' => 'secret=91009123',
300 | ];
301 |
302 | Then of course the url you give google for testing is:
303 | https://www.example.com/?secret=91009123
304 |
305 | Staging instance that needs to unblock frontend for IP=11.11.11.11
306 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307 |
308 | ::
309 |
310 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
311 | 'ip' => '11.11.11.11',
312 | ];
313 |
314 | Example how the AND condition looks like
315 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 |
317 | ip and header are AND'ed. array values inside ip and header are OR'ed.
318 |
319 | ::
320 |
321 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions'] = [
322 | 'AND' => [
323 | 'ip' => [
324 | '66.249.64.0/19'
325 | '66.249.44.0/19'
326 | ],
327 | 'header' => [
328 | 'HTTP_USER_AGENT=Google Page Speed Insights'
329 | 'HTTP_USER_AGENT=Google Page Speed'
330 | ],
331 | ]
332 | ]
333 | ];
334 |
335 |
336 | Default Configuration
337 | ~~~~~~~~~~~~~~~~~~~~~
338 |
339 | By default following configuration is applied. You can change every
340 | element of this array using ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']``
341 |
342 | ::
343 |
344 | [
345 | 'templatePath' => ExtensionManagementUtility::siteRelPath('restrictfe').'Resources/Private/Templates/Restricted.html',
346 | 'cookie' => [
347 | 'expire' => time() + 86400 * 30,
348 | 'path' => '/',
349 | 'domain' => null,
350 | 'secure' => ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['cookieSecure'] === 1 || GeneralUtility::getIndpEnv('TYPO3_SSL')),
351 | 'httponly' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['cookieHttpOnly'],
352 | ],
353 | 'exceptions' => [
354 | 'backendUser' => true,
355 | 'ip' => '127.0.0.1',
356 | ],
357 | ];
358 |
359 |
360 | FAQ
361 | ---
362 |
363 | - **Extension does not work. The frontend is not blocked at all. What is wrong?**
364 | Be sure you are logged from BE and the cookie "restrictfe" is deleted. Remember also that
365 | restrictfe protection is not working if $_SERVER['REMOTE_ADDR'] == 127.0.0.1 so if you
366 | are working on your local instance restrictfe is disabled. To enable it on your local instance
367 | insert folowing line:
368 | ``$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['exceptions']['ip'] = '__UNSET';``
369 |
370 | - **I am logged out from BE but still frontend is not blocked, why?**
371 | From 3.0.0. version after first successful login a cookie is set
372 | (name tx\_restrictfe). If that cookie is present then user do not
373 | have to authorize again. So delete that cookie and then your frontend
374 | should be blocked again.
375 |
376 |
377 | Known problems
378 | --------------
379 |
380 | None.
381 |
382 | To-Do list
383 | ----------
384 |
385 | 1. Add userFunc for conditions
386 | 2. Add pregmatch for all conditions like '~domain'
387 | 3. Add support for detecting browser language to see proper lang on
388 | "you must log to see the website" warning screen.
389 | 4. Make unit tests for conditions array.
390 |
391 |
392 | Changelog
393 | ---------
394 |
395 | See https://github.com/sourcebroker/restrictfe/blob/master/CHANGELOG.rst
396 |
--------------------------------------------------------------------------------
/Classes/Middleware/RequestCheck.php:
--------------------------------------------------------------------------------
1 | configBuilder = $configBuilder;
25 | $this->config = $this->configBuilder->get();
26 | }
27 |
28 | /**
29 | * @param ServerRequestInterface $request
30 | * @param RequestHandlerInterface $handler
31 | *
32 | * @return ResponseInterface
33 | * @throws Throwable
34 | */
35 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
36 | {
37 | $this->request = $request;
38 | $this->checkExceptionsAndBlockFrontendIfNeeded();
39 | return $handler->handle($request);
40 | }
41 |
42 | /**
43 | * Check for all exceptions defined and block frontend if needed
44 | */
45 | public function checkExceptionsAndBlockFrontendIfNeeded(): void
46 | {
47 | $blockFrontendAccess = true;
48 | if (isset($this->config['exceptions']) && is_array($this->config['exceptions'])
49 | && true === $this->checkRules($this->config['exceptions'])) {
50 | $blockFrontendAccess = false;
51 | }
52 | if (true === $blockFrontendAccess) {
53 | $templatePath = GeneralUtility::getFileAbsFileName($this->config['templatePath']);
54 | if (!file_exists($templatePath)) {
55 | throw new RuntimeException('Template file can not be found:' . $templatePath);
56 | }
57 | $beLoginLink = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
58 | $templateContent = file_get_contents($templatePath);
59 | if ($templateContent === false) {
60 | throw new RuntimeException('Could not read template file content:' . $templatePath);
61 | }
62 | $outputContent = str_replace('{beLoginLink}', $beLoginLink, $templateContent);
63 |
64 | setcookie(
65 | 'tx_restrictfe_redirect',
66 | GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'),
67 | 0,
68 | '/',
69 | $this->config['cookie']['domain'],
70 | true,
71 | true);
72 |
73 | header('X-Robots-Tag: noindex,nofollow');
74 | header('HTTP/1.0 403 Access Forbidden');
75 | header('Content-Type: text/html; charset=utf-8');
76 | header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
77 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
78 | header('Cache-Control: no-store, no-cache, must-revalidate');
79 | header('Cache-Control: pre-check=0, post-check=0, max-age=0');
80 | header('Pragma: no-cache');
81 | header('Expires: 0');
82 |
83 | echo $outputContent;
84 | exit();
85 | }
86 | }
87 |
88 | /**
89 | * @param string $conditionType
90 | * @param mixed $conditionValues
91 | * @return bool
92 | */
93 | protected function checkCondition(string $conditionType, $conditionValues): bool
94 | {
95 | if (!is_array($conditionValues)) {
96 | $conditionValues = [$conditionValues];
97 | }
98 | $conditionResult = false;
99 | switch ($conditionType) {
100 | // Special condition. It will just return value of the condition
101 | case '*':
102 | $conditionResult = $conditionValues[0];
103 | break;
104 |
105 | case 'get':
106 | foreach ($conditionValues as $conditionValue) {
107 | [$getName, $getValue] = explode('=', $conditionValue);
108 | if (($this->request->getQueryParams()[trim($getName)] ?? null) === trim($getValue)) {
109 | $conditionResult = true;
110 | break;
111 | }
112 | }
113 | break;
114 |
115 | case '!get':
116 | $conditionResults = [];
117 | foreach ($conditionValues as $conditionValue) {
118 | [$getName, $getValue] = explode('=', $conditionValue);
119 | if (($this->request->getQueryParams()[trim($getName)] ?? null) !== trim($getValue)) {
120 | $conditionResults[] = true;
121 | } else {
122 | $conditionResults[] = false;
123 | }
124 | }
125 | $uniqueConditionResults = array_unique($conditionResults);
126 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
127 | $conditionResult = true;
128 | }
129 | break;
130 |
131 | case 'post':
132 | foreach ($conditionValues as $conditionValue) {
133 | [$postName, $postValue] = explode('=', $conditionValue);
134 | if (($this->request->getParsedBody()[trim($postName)] ?? null) === trim($postValue)) {
135 | $conditionResult = true;
136 | break;
137 | }
138 | }
139 | break;
140 |
141 | case '!post':
142 | $conditionResults = [];
143 | foreach ($conditionValues as $conditionValue) {
144 | [$postName, $postValue] = explode('=', $conditionValue);
145 | if (($this->request->getParsedBody()[trim($postName)] ?? null) !== trim($postValue)) {
146 | $conditionResults[] = true;
147 | } else {
148 | $conditionResults[] = false;
149 | }
150 | }
151 | $uniqueConditionResults = array_unique($conditionResults);
152 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
153 | $conditionResult = true;
154 | }
155 | break;
156 |
157 | case 'requestUri':
158 | foreach ($conditionValues as $conditionValue) {
159 | if (strpos(GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT'), trim($conditionValue)) === 0) {
160 | $conditionResult = true;
161 | break;
162 | }
163 | }
164 | break;
165 |
166 | case '!requestUri':
167 | $conditionResults = [];
168 | foreach ($conditionValues as $conditionValue) {
169 | if (strpos(GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT'), trim($conditionValue)) !== 0) {
170 | $conditionResults[] = true;
171 | } else {
172 | $conditionResults[] = false;
173 | }
174 | }
175 | $uniqueConditionResults = array_unique($conditionResults);
176 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
177 | $conditionResult = true;
178 | }
179 | break;
180 |
181 | case 'ip':
182 | foreach ($conditionValues as $conditionValue) {
183 | if (GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $conditionValue)) {
184 | $conditionResult = true;
185 | break;
186 | }
187 | }
188 | break;
189 |
190 | case '!ip':
191 | $conditionResults = [];
192 | foreach ($conditionValues as $conditionValue) {
193 | if (!GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $conditionValue)) {
194 | $conditionResults[] = true;
195 | } else {
196 | $conditionResults[] = false;
197 | }
198 | }
199 | $uniqueConditionResults = array_unique($conditionResults);
200 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
201 | $conditionResult = true;
202 | }
203 | break;
204 |
205 | case 'domain':
206 | foreach ($conditionValues as $conditionValue) {
207 | if ($conditionValue === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) {
208 | $conditionResult = true;
209 | break;
210 | }
211 | }
212 | break;
213 |
214 | case '!domain':
215 | $conditionResults = [];
216 | foreach ($conditionValues as $conditionValue) {
217 | if ($conditionValue !== GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) {
218 | $conditionResults[] = true;
219 | } else {
220 | $conditionResults[] = false;
221 | }
222 | }
223 | $uniqueConditionResults = array_unique($conditionResults);
224 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
225 | $conditionResult = true;
226 | }
227 | break;
228 |
229 | case 'header':
230 | foreach ($conditionValues as $conditionValue) {
231 | [$headerName, $headerValue] = explode('=', $conditionValue);
232 | if (trim($headerValue) === $this->getHeaderValue($headerName)) {
233 | $conditionResult = true;
234 | break;
235 | }
236 | }
237 | break;
238 |
239 | case '!header':
240 | $conditionResults = [];
241 | foreach ($conditionValues as $conditionValue) {
242 | [$headerName, $headerValue] = explode('=', $conditionValue);
243 | if (trim($headerValue) !== $this->getHeaderValue($headerName)) {
244 | $conditionResults[] = true;
245 | } else {
246 | $conditionResults[] = false;
247 | }
248 | }
249 | $uniqueConditionResults = array_unique($conditionResults);
250 | if (1 === count($uniqueConditionResults) && true === reset($uniqueConditionResults)) {
251 | $conditionResult = true;
252 | }
253 | break;
254 |
255 | case 'backendUser':
256 | foreach ($conditionValues as $conditionValue) {
257 | if (is_bool($conditionValue)) {
258 | if (true === $conditionValue) {
259 | $conditionResult = false;
260 | if (
261 | isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['beLogged'])
262 | && $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['restrictfe']['beLogged'] === true
263 | ) {
264 | $conditionResult = true;
265 | }
266 | $cookieParams = $this->request->getCookieParams();
267 | if (isset($cookieParams['tx_restrictfe'])) {
268 | if (true === GeneralUtility::makeInstance(Registry::class)->get(
269 | 'tx_restrictfe',
270 | (int)$cookieParams['tx_restrictfe'])
271 | ) {
272 | $conditionResult = true;
273 | } else {
274 | // Cookie exist but is wrong so unset it.
275 | setcookie(
276 | 'tx_restrictfe',
277 | '',
278 | $this->config['cookie']['expire'],
279 | $this->config['cookie']['path'],
280 | $this->config['cookie']['domain'],
281 | $this->config['cookie']['secure'],
282 | $this->config['cookie']['httponly']);
283 | }
284 | }
285 | }
286 | } else {
287 | throw new RuntimeException('Extension restrictfe: The $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'restrictfe\'][\'exception\'][\'backendUser\'] must be boolean type.');
288 | }
289 | }
290 | break;
291 |
292 | default:
293 | throw new RuntimeException('Extension restrictfe: The condition: "' . $conditionType . '" is not supported.');
294 | }
295 | return $conditionResult;
296 | }
297 |
298 | /**
299 | * @param $conditions
300 | * @param string $type
301 | *
302 | * @return bool
303 | */
304 | protected function checkRules($conditions, string $type = 'OR'): bool
305 | {
306 | // early return for always true
307 | if (array_key_exists('*', $conditions)) {
308 | return true;
309 | }
310 | $conditionResults = [];
311 | foreach ($conditions as $conditionType => $conditionValue) {
312 | if ($conditionType === 'AND' || $conditionType === 'OR') {
313 | $conditionResult = $this->checkRules($conditionValue, $conditionType);
314 | } else {
315 | $conditionResult = $this->checkCondition($conditionType, $conditionValue);
316 | }
317 | $conditionResults[$conditionType] = $conditionResult;
318 | if ('OR' === $type && true === $conditionResult) {
319 | break;
320 | }
321 | }
322 | $finalResult = false;
323 | switch ($type) {
324 | case 'AND':
325 | if (reset($conditionResults) === true && count(array_unique(array_values($conditionResults))) === 1) {
326 | $finalResult = true;
327 | }
328 | break;
329 | case 'OR':
330 | if (count(array_unique(array_values($conditionResults))) === 2
331 | || (count(array_unique(array_values($conditionResults))) === 1 && reset($conditionResults) !== false)
332 | ) {
333 | $finalResult = true;
334 | }
335 | break;
336 | }
337 | return $finalResult;
338 | }
339 |
340 | protected function getHeaderValue(string $headerName): ?string
341 | {
342 | $headerName = 'http_' . str_replace('-', '_', strtolower(trim($headerName)));
343 | $tmpServer = [];
344 | foreach ($_SERVER as $key => $value) {
345 | $tmpServer[str_replace('-', '_', strtolower($key))] = $value;
346 | }
347 | return !empty($tmpServer[$headerName]) ? $tmpServer[$headerName] : null;
348 | }
349 | }
350 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------