Go to file
Artyom 02b7fd6599 Implement PushmessageProviderService method in FCM service 2022-08-16 14:32:36 +03:00
captcha Miscellaneous changes (#50) 2021-08-19 20:07:41 +03:00
common Add page interfaces (#67) 2022-02-18 19:54:07 +03:00
common-geo rename GeoHelper -> GeoCalculator 2021-06-08 20:24:32 +03:00
common-geo-spatial4j-spring review fixes 2021-06-08 20:29:33 +03:00
common-measure fix linter 2021-06-15 19:06:50 +03:00
common-measure-spring add common-measure 2021-06-08 19:48:08 +03:00
common-messaging Add common-messaging (#51) 2021-08-26 15:25:00 +03:00
common-spring add common-spring 2021-06-06 22:35:20 +03:00
common-spring-jpa Add support for multiple instances of LiquibaseParams (#73) 2022-05-17 13:23:52 +03:00
common-spring-security fix linter 2021-06-15 19:06:50 +03:00
common-spring-security-jpa fix migrations, refresh token 2021-06-27 10:23:26 +03:00
common-spring-test add common-spring-test 2021-06-06 22:55:02 +03:00
common-spring-test-jpa add test-slow profile to RepositoryTestConfiguration 2021-06-10 18:41:01 +03:00
common-spring-web add missing value resolver (#55) 2021-11-03 15:57:30 +03:00
common-territories Add geoip-core (#74) 2022-05-25 17:56:18 +03:00
exception-handler-logger-spring-web add @EnableSpringExceptionHandlerLogger 2021-06-15 20:31:58 +03:00
exception-handler-spring-security-web Miscellaneous changes (#50) 2021-08-19 20:07:41 +03:00
exception-handler-spring-web Added httpHeaders in ExceptionHandlerAdvice (#70) 2022-03-30 14:40:16 +03:00
geoip-core Remove geoip schema creation script (#75) 2022-05-26 13:41:20 +03:00
gradle/wrapper add common module 2021-06-06 19:19:46 +03:00
logger Add DateTime serializer (#53) 2021-10-09 14:41:21 +03:00
logger-spring Miscellaneous changes (#50) 2021-08-19 20:07:41 +03:00
logger-spring-web Miscellaneous changes (#50) 2021-08-19 20:07:41 +03:00
push-message-provider Add method to PushMessageProviderService interface 2022-08-16 13:35:29 +03:00
push-message-provider-fcm Implement PushmessageProviderService method in FCM service 2022-08-16 14:32:36 +03:00
response-wrapper-spring-web rename wrap annotations 2021-06-08 18:21:02 +03:00
s3-storage Added property endpoint (#76) 2022-07-14 16:02:02 +03:00
security-authorization-server-core Added setPassword method, dto (#69) 2022-03-22 19:40:44 +03:00
security-authorization-server-jwt-core More auth refactoring (#47) 2021-08-18 13:22:19 +03:00
security-authorization-server-oauth2-metadata Refactor auth modules (#46) 2021-08-17 10:47:00 +03:00
security-jwt-common Refactor auth modules (#46) 2021-08-17 10:47:00 +03:00
security-resource-server-custom-jwt-configuration More auth refactoring (#47) 2021-08-18 13:22:19 +03:00
security-resource-server-default-jwt-configuration More auth refactoring (#47) 2021-08-18 13:22:19 +03:00
security-resource-server-test-jwt-configuration More auth refactoring (#47) 2021-08-18 13:22:19 +03:00
server-info-spring-web Feature/add server info controller (#72) 2022-04-11 14:45:17 +03:00
settings-spring-jpa fix linter 2021-06-15 19:06:50 +03:00
validation-spring fix email regexp (#54) 2021-10-23 00:19:02 +03:00
version-spring-web rename version annotations 2021-06-08 15:23:16 +03:00
.editorconfig add common module 2021-06-06 19:19:46 +03:00
.gitignore add common module 2021-06-06 19:19:46 +03:00
LICENSE add Apache 2.0 License 2021-06-06 21:39:21 +03:00
README.md Push message provider modules (#77) 2022-08-12 16:59:59 +03:00
build.gradle.kts Push message provider modules (#77) 2022-08-12 16:59:59 +03:00
gradle.properties Miscellaneous changes (#50) 2021-08-19 20:07:41 +03:00
gradlew add common module 2021-06-06 19:19:46 +03:00
gradlew.bat add common module 2021-06-06 19:19:46 +03:00
settings.gradle.kts Push message provider modules (#77) 2022-08-12 16:59:59 +03:00

README.md

Modules

Installation via Gradle Composite Build

  1. Add this repository as a git submodule to your project

  2. Add these lines to your settings.gradle.kts:

    includeBuild("Backend-common")
    
  3. Use TLK modules as dependencies of your project

    dependencies {
        implementation("ru.touchin:common")
    }
    

common

Набор утилит, структур данных, исключений без привязки к spring

  • ExecutionContext - класс для хранения/получения данных из текущего потока
  • SecureRandomStringGenerator - генератор случайной строки по словарю
  • errors.* - базовые исключения
  • <type>.*Utils - утилиты для различных типов данных

common-spring

Набор утилит, структур данных для spring, без привязки к доп. модулям, таким как jpa и web

common-spring-jpa

  • models.* - базовые Entity
  • repositories - утилиты и доп. интерфейсы для репозиториев
  • liquibase.LiquibaseStart - для подключения этого компонента необходимо объявить liquibase.LiquibaseParams. Указать путь к файлу с миграцией и схему, для которой эта миграция будет применяться. С помощью LiquibaseStart можно применить кастомную миграцию не конфликтуя с основной.
  • EnableJpaAuditingExtra - подключение JpaAuditing с поддержкой типа ZoneDateTime

common-spring-web

  • request.Utils - различные extensions для работы с HttpServletRequest
  • errors.* - исключения и типы данных для web
  • webclient.* - классы для расширения webclient, включая логирование

common-spring-security

  • configurations.DefaultSecurityConfiguration - дефолтная реализация WebSecurity, определяет для каких request path надо ограничить доступ. Использует url.interceptors.UrlExpressionRegistryInterceptor для принятия решения.
  • auditor.AuditorResolver - служит для преобразования principal в строку, используется с JpaAuditing

common-spring-security-jpa

  • auditor.SecurityAuditorAware - резолвит имя пользователя для полей @CreatedBy, @LastModifiedBy. Требуется явно создать бин AuditorAware<String> в проекте.

common-spring-test

Утилиты для тестирования в среде spring-test

common-spring-test-jpa

Утилиты для тестирования репозиториев

logger

Основные компоненты логирования:

  • layout
  • context
  • format

logger-spring

Встраивание системы логирования в spring

  • autologging
  • serializer

logger-spring-web

Interceptor для логирования запросов/ответов.

exception-handler-spring-web

Перехватывает ошибки сервера, определяет код ошибки и возвращает их в правильный response. Подключается с помощью аннотации @EnableSpringExceptionHandler

exception-handler-logger-spring-web

Добавляет логирование в обработку ошибок. Подключается с помощью аннотации @EnableSpringExceptionHandlerLogger до подключения основного модуля.

validation-spring

Добавляет аннотации для валидации запросов.

version-spring-web

Добавляет возможность задавать версию апи через properties без необходимости явно указывать в каждом маппинге

response-wrapper-spring-web

Добавляет обертку для успешного ответа

common-measure

Утилиты для работы с measure

common-measure-spring

Возможность задавать measure через properties

common-geo

Интерфейс для работы с гео-данными

common-geo-spatial4j-spring

Реализация интерфейса GeoCalculator с помощью библиотеки spatial4j

settings-spring-jpa

Модуль для хранения настроек

security-authorization-server-core

Модуль авторизации

security-authorization-server-jwt-core

Добавляет поддержку jwt-токенов (создание/хранение). Для работы этого модуля требуется прописать в пропертях:

token.access:
  issuer: ${app.issuer}
  timeToLive: PT15M # 15 minutes
  signatureAlgorithm: RS256
  keyPair:
    public: |
      -----BEGIN PUBLIC KEY-----
      -----END PUBLIC KEY-----      
    private: |
      -----BEGIN PRIVATE KEY-----
      -----END PRIVATE KEY-----      
token.refresh:
  length: 20
  prefix: RT-
  timeToLive: PT2H # 2 hours

Генерация ключей:

openssl genrsa -out private.pem 4096
openssl rsa -in private.pem -pubout -out public.pem
openssl pkcs8 -topk8 -inform PEM -in private.pem -out private_key.pem -nocrypt

cat private_key.pem
cat public.pem

security-authorization-server-oauth2-metadata

OAuth2 metadata support.

security-jwt-common

JWT related utilities.

security-resource-server-default-configuration

Default configuration for the Spring OAuth2 resource server with JWT auth.

security-resource-server-custom-configuration

Custom configuration for the Spring OAuth2 resource server with JWT auth. Requires the following properties:

token.access:
  issuer: ${app.issuer}
  signatureAlgorithm: RS256
  keyPair:
    public: |
      -----BEGIN PUBLIC KEY-----
      -----END PUBLIC KEY-----      

security-resource-server-test-configuration

Disables Spring OAuth2 resource server for testing.

s3-storage

Amazon S3 support.

server-info-spring-web

Allow include headers with information about the server in responses

To get started you need:

  1. Add annotation to configuration
  2. Add property to yml/properties file:
server.info:
    buildVersion: ${buildVersion}
  1. Implement ServerInfoService (optional. If you want to add other headers)
  2. Add dir with impl ServerInfoService in ComponentScan annotation

push-message-provider

Интерфейсы и компоненты для модулей по обеспечению интеграции с сервисами отправки пуш-уведомлений.

push-message-provider-fcm

Модуль по обеспечению интеграции с Firebase Cloud Messaging.

  1. Подключение компонентов Spring осуществляется при помощи аннотации @EnablePushMessageProviderFcm.
  2. Необходимо добавление конфигурации для модуля. Пример файла конфигурации в формате yaml:
push-message-provider:
  platformProviders:
    ANDROID_GOOGLE:
      - FCM
    IOS:
      - FCM
  fcm:
    appName: ${appName}
    auth:
      resourcePath: credentials/firebase-admin.json
    client:
      readTimeout: 10s
      connectionTimeout: 1s
  1. По обозначенному пути push-message-provider-fcm.auth.resourcePath добавляется json файл с настройками и доступами из консоли Firebase.