安全概述


Red Hat build of Quarkus 3.27

Red Hat Customer Content Services

摘要

Quarkus Security 为 Java 应用程序安全性提供了一个完整的框架,合并不同的身份验证方法、基于角色的访问控制(RBAC)和功能,如 SSL/TLS。本指南涵盖了其主要功能、设置和测试,面向将安全性集成到 Quarkus 应用程序的开发人员。

第 1 章 Quarkus 安全概述

Quarkus Security 是一个框架,它提供架构、多个身份验证和授权机制,以及其他工具来构建安全、生产质量的 Java 应用程序。

在您的 Quarkus 应用程序中构建安全前,了解 Quarkus 安全架构 和您可以使用的不同身份验证机制和功能。

1.1. Quarkus 安全的主要功能

Quarkus 安全框架为 Basic、Form-based 和 mutual TLS (mTLS)身份验证提供了内置的安全身份验证机制。您还可以使用其他已知的 身份验证机制,如 OpenID Connect (OIDC)。身份验证机制取决于 身份提供程序 来验证身份验证凭据,并将它们映射到具有用户名、角色、原始身份验证凭据和其他属性的 SecurityIdentity 实例。

Quarkus 还包括内置的安全性,以允许基于常见安全注释 @RolesAllowed@DenyAll@PermitAll on REST 端点以及 Contexts 和 Dependency Injection (CDI) Bean 进行基于角色的访问控制(RBAC)。如需更多信息,请参阅 Web 端点指南的 Quarkus 授权 指南。

Quarkus 安全还支持以下功能:

Quarkus Security 也可高度自定义。如需更多信息,请参阅 Quarkus 安全提示和技巧 指南。

1.2. Quarkus 安全入门

要开始使用 Quarkus 中的安全,请考虑使用内置 Quarkus 基本身份验证 和 Jakarta Persistence 身份提供程序以及启用基于角色的访问控制来保护 Quarkus 应用程序端点。

使用基本身份验证和 Jakarta Persistence 教程 完成 Getting started with Security 中的步骤。

使用基本身份验证成功保护 Quarkus 应用程序后,您可以通过添加更多高级身份验证机制来进一步提高安全性,例如 Quarkus OpenID Connect (OIDC)授权代码流机制

1.3. Quarkus 安全测试

有关测试 Quarkus 安全功能并确保您的 Quarkus 应用程序安全保护的指南,请参阅 安全测试 指南。

1.4. Quarkus 中的安全功能的更多信息

1.4.1. Websocket 下一步安全性

quarkus-websockets-next 扩展提供 WebSocket API 的现代、高效的实现。它还提供与 Quarkus 安全性的集成。如需更多信息,请参阅 Quarkus "WebSockets Next reference" 指南中的 Security 部分。

1.4.2. 跨原始资源共享

要使 Quarkus 应用程序可供在不同域上运行的另一个应用程序访问,您需要配置跨原始资源共享(CORS)。有关 CORS 过滤器 Quarkus 的更多信息,请参阅 Quarkus "Cross-origin 资源共享" 指南中的 CORS 过滤器 部分。

1.4.3. 跨站点请求 Forgery (CSRF)防止

Quarkus Security 提供了一个 Quarkus REST (以前为 RESTEasy Reactive)过滤,它可以防止您的应用程序免受 跨站点请求 Forgery 攻击。如需更多信息,请参阅 Quarkus cross -Site Request Forgery Prevention 指南。

1.4.4. SameSite cookies

您可以将 SameSite cookie 属性添加到 Quarkus 端点设置的任何 Cookie 中。如需更多信息,请参阅 Quarkus "HTTP 参考" 指南中的 SameSite cookies 部分。

1.4.5. Secret 引擎

您可以使用带有 Quarkus 的 secret 引擎来存储、生成或加密数据。

Quarkus 提供了 Quarkiverse 中用于安全存储凭证的额外扩展,如 Quarkus 和 HashiCorp Vault

1.5. 环境属性中的 secret

Quarkus 支持将 secret 存储在环境属性中。如需更多信息,请参阅 环境文件指南中的 Quarkus 存储 secret

1.5.1. 安全序列化

如果您的 Quarkus 安全架构包含 Quarkus REST (以前为 RESTEasy Reactive)和 Jackson,则 Quarkus 可以根据配置的安全性限制 JSON 序列化中包含的字段。如需更多信息,请参阅 Quarkus "Writing REST services with Quarkus REST (以前称为 RESTEasy Reactive)" 指南中的 JSON 序列化 部分。

如果您使用带有 Panache 扩展的 REST 数据自动生成资源,您仍可在软件包 jakarta.annotation.security 中使用安全注解。如需更多信息,请参阅 Quarkus "Generating Jakarta REST resources with Panache" 指南中的 保护端点 部分。

1.6. 安全漏洞检测

大多数 Quarkus 标签在美国 国家漏洞数据库(NVD)中报告。有关安全漏洞的详情,请查看 Quarkus 指南中的安全漏洞检测和报告

1.7. 参考

法律通告

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat