A Symfony bundle that provides #StandWithUkraine banner and has some built-in features to block access to your resource for Russian-speaking users.

Overview

StandWithUkraineBundle

Stand With Ukraine

CI

На русском? Смотри README.ru.md

This bundle provides a built-in StandWithUkraine banner for your Symfony application and has some features to block content for Russian-speaking users. Why? Great question! There is a war in Ukraine right now. You can read more about it here.

The initial idea of this bundle is to push Russian-speaking people to think! Almost all Russian media are not independent anymore and spread fake news to their users about what is happening in the world and even in their own country. Everybody has a choice. You can choose different sources in different languages to read the news from many other independent and trusted media around the world, don't limit yourself with Russian language and Russian media only.

Features

Some features included in this bundle:

  • Display "StandWithUkraine" banner to show that your website stands united with the people of Ukraine. Example of StandWithUkraine banner
  • Block content for users who have the preferred language in Accept-Language request header set to ru. Basically, affects people who read most of the content in Russian language. Users would be able to access the content only after changing their preferred language to any other language. They still can keep Russian language, but as a secondary one. Example of access denied page
  • Block content for users who are trying to get access from Russian IP addresses, i.e. accessing the content from Russia. Users would be able to access the content only after connecting via a VPN client choosing a location different from Russia region there. It makes things less convenient probably, but if you're using a good VPN client - you get better security, especially if you're connecting from public Wi-Fi spots or do not trust your internet provider. Example of access denied page

Demo

Want to see this bundle in action before installing it? Check a little demo:

Thanks to Heroku for hosting it ❤️

Installation

Install with Composer:

$ symfony composer require bw/stand-with-ukraine-bundle

Then, enable the bundle if you don't use Symfony Flex:

// config/bundles.php

return [
    // ...
    BW\StandWithUkraineBundle\StandWithUkraineBundle::class => ['all' => true],
];

And then activate/deactivate event subscribers in its configuration.

Configuration

Configuration is optional, all options have defaults. But if you want to change it - create a config file config/services/stand_with_ukraine.yaml and tweak it. Below you can find the full configuration example with the defaults values:

# config/packages/stand_with_ukraine.yaml

stand_with_ukraine:
    banner:
        enabled:              true

        # Possition of the banner: "top" or "bottom"
        position:             top

        # Wrap the banner with a link to the given URL
        target_url:           null

        # Will be shown in the banner, HTTP host by default
        brand_name:           null
    ban_language:
        enabled:              true
        use_links:            true
    ban_country:
        enabled:              true
        use_links:            true

Or you can see it in your terminal, just run:

$ symfony console config:dump-reference stand_with_ukraine

Testing

For testing purposes, you can easily simulate bad requests to test things manually on your website in an easy way. To overwrite the actual country code with ru, use swu_overwrite_country_code_ru query parameter, i.e:

https://127.0.0.1:8000/?swu_overwrite_country_code_ru=yes

Also, you can overwrite preferred language with ru as well, use swu_overwrite_preferred_lang_ru query parameter, i.e:

https://127.0.0.1:8000/?swu_overwrite_preferred_lang_ru=yes

The system will thinks that you're sending requests from a Russian IP address or with Russian preferred language correspondingly and behave accordingly your configuration.

That's it!

Thanks for using this bundle! Feel free to create an issue or send a PR if you have any ideas how to improve it. And if you like it - please, share!

You might also like...
Mediator - CQRS Symfony bundle. Auto Command/Query routing to corresponding handlers.

Installation $ composer require whsv26/mediator Bundle configuration // config/packages/mediator.php return static function (MediatorConfig $config)

Symfony bundle for EventSauce (WIP)

Symfony EventSauce (WIP) This bundle provides the basic and extended container configuration of symfony for the EventSauce library. Before using it, I

Symfony bundle integrating server-sent native notifications
Symfony bundle integrating server-sent native notifications

Symfony UX Notify Symfony UX Notify is a Symfony bundle integrating server-sent native notifications in Symfony applications using Mercure. It is part

Bundle to integrate Tactician with Symfony projects

TacticianBundle Symfony2 Bundle for the Tactician library https://github.com/thephpleague/tactician/ Installation Step 1: Download the Bundle Open a c

A PHP replacement layer for the C intl extension that also provides access to the localization data of the ICU library.

A PHP replacement layer for the C intl extension that also provides access to the localization data of the ICU library.

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

CORS Middleware for Laravel Implements https://github.com/asm89/stack-cors for Laravel About The laravel-cors package allows you to send Cross-Origin

Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array.

Drest Dress up doctrine entities and expose them as REST resources This library allows you to quickly annotate your doctrine entities into restful res

EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

WPGraphQL Block Editor This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on

OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

Comments
  • Change event subscriber priorities

    Change event subscriber priorities

    The priority of subscribers might be too aggressive. We have 13 and 14 for them which are too close to the system's 15 | "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest(RequestEvent $event): void". There's literally no space between ours CountrySubscriber and system's LocaleAwareListener. We need to get lower those priorities. It just should be greater than the default's 0 priority at least, but making them higher will mean less code from other listeners will be executed for blocked requests. Let's use 11 and 12, it should leave enough space up to the system's LocaleAwareListener, but also high enough to get ahead of lower listeners

    opened by bocharsky-bw 0
Releases(v0.1.2)
  • v0.1.2(Jun 4, 2022)

    What's Changed

    • Translate more text by @bocharsky-bw in https://github.com/bocharsky-bw/stand-with-ukraine-bundle/pull/2
    • Change priorities for listeners by @bocharsky-bw in https://github.com/bocharsky-bw/stand-with-ukraine-bundle/pull/3

    New Contributors

    • @bocharsky-bw made their first contribution in https://github.com/bocharsky-bw/stand-with-ukraine-bundle/pull/4

    Full Changelog: https://github.com/bocharsky-bw/stand-with-ukraine-bundle/compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(May 3, 2022)

    Fix setting styles to the banner links only

    Full Changelog: https://github.com/bocharsky-bw/stand-with-ukraine-bundle/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(May 3, 2022)

    The first release! Give it a try, and share your feedback!

    What to see in action? Check a demo:

    • https://stand-with-ukraine-bundle.herokuapp.com/
    • https://stand-with-ukraine-bundle.herokuapp.com/en/?swu_overwrite_country_code_ru=yes
    • https://stand-with-ukraine-bundle.herokuapp.com/en/?swu_overwrite_preferred_lang_ru=yes

    Full Changelog: https://github.com/bocharsky-bw/stand-with-ukraine-bundle/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Victor Bocharsky
PHP developer, course writer, help scout, and expanding code blocks ninja at @SymfonyCasts - implement, merge, and deploy new features. #StandWithUkraine 🇺🇦
Victor Bocharsky
This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

PHP API TO-DO-LIST v.2.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science cours

Edson M. de Souza 6 Oct 13, 2022
Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project

AmiAirbrakeBundle Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project. Prerequisites Th

Anton Minin 8 May 6, 2022
CORS (Cross-Origin Resource Sharing) for your Symfony/Laravel requests

CORS for PHP (using the Symfony HttpFoundation) Library and middleware enabling cross-origin resource sharing for your http-{foundation,kernel} using

Fruitcake 91 Dec 22, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
A bundle providing routes and glue code between Symfony and a WOPI connector.

WOPI Bundle A Symfony bundle to facilitate the implementation of the WOPI endpoints and protocol. Description The Web Application Open Platform Interf

Champs-Libres 5 Aug 20, 2022
Pure PHP implementation of GraphQL Server – Symfony Bundle

Symfony GraphQl Bundle This is a bundle based on the pure PHP GraphQL Server implementation This bundle provides you with: Full compatibility with the

null 283 Dec 15, 2022
DataTables bundle for Symfony

Symfony DataTables Bundle This bundle provides convenient integration of the popular DataTables jQuery library for realtime Ajax tables in your Symfon

Omines Internetbureau 199 Jan 3, 2023
GraphQL Bundle for Symfony 2.

Symfony 2 GraphQl Bundle Use Facebook GraphQL with Symfony 2. This library port laravel-graphql. It is based on the PHP implementation here. Installat

Sergey Varibrus 35 Nov 17, 2022
An Unleash bundle for Symfony applications to provide an easy way to use feature flags

Unleash Bundle An Unleash bundle for Symfony applications. This provide an easy way to implement feature flags using Gitlab Feature Flags Feature. Ins

Stogon 7 Oct 20, 2022
Symfony Health Check Bundle Monitoring Project Status

Symfony Health Check Bundle Version Build Status Code Coverage master develop Installation Step 1: Download the Bundle Open a command console, enter y

MacPaw Inc. 27 Jul 7, 2022