Существует множество рекомендаций, примеры кода, которые показывают, как защитить REST API с помощью Spring Безопасность, но большинство из них предполагает веб-клиент и говорит о странице входа в систему, перенаправлении, использовании файла cookie и т.д. Может быть, даже простой фильтра, который проверяет собственный токен в заголовке HTTP, может быть достаточно. Как я могу обеспечить безопасность для требований ниже? Есть ли какой-либо проект gist/github, который делает то же самое? Мои знания в Spring безопасности ограничены, поэтому, если есть более простой способ реализовать это с помощью безопасности Spring, пожалуйста, дайте мне знать.
- API REST, обслуживаемый безстоящим бэкэнд над HTTPS
- клиент может быть веб-приложением, мобильным приложением, любым приложением SPA-стиля, сторонними API-интерфейсами.
- нет Basic Auth, нет файлов cookie, нет пользовательского интерфейса (нет JSP/HTML/статических ресурсов), нет перенаправления, нет поставщика OAuth.
- настраиваемый токен, установленный в заголовках HTTPS
- Проверка маркера, выполняемая против внешнего хранилища (например, MemCached/Redis/или даже любая СУБД)
- Все API-интерфейсы должны быть аутентифицированы, за исключением выбранных путей (например,/login,/signup,/public и т.д.).
Я использую Springboot, Spring безопасность и т.д. предпочитаю решение с конфигурацией Java (без XML)