spring - 如何使用spring boot根据参数值保护具有不同身份验证的单页应用程序?
问题描述
我正在使用 Spring Boot 做一个 Web 应用程序。Web 应用程序基本上是用于创建类似于 Oracle Application Express 的 Web 应用程序的工具/构建器。它只有一个页面/视图(f.html),它是动态的,因为它根据参数值显示不同的布局。只有一个参数名为“p”。此参数是应用程序 ID/代码、页面 ID/代码等的串联。
例如:
f?p=HR:EMPLOYEES:[items]:[values] 这基本上意味着 HR 是应用程序,EMPLOYEES 是页面,[items] 对于页面项目是可选的,而 [values] 对于项目值是可选的。解析将由控制器处理。
我有一个包含此表的数据库。例如:
create table web_applications (
id bigint auto_increment
, code varchar(30) not null
, name varchar(255) not null
, description varchar(255)
, workspace_id bigint
, created_on datetime
, last_updated_on datetime
, created_by bigint
, last_updated_by bigint
, primary key ( id ) );
create table web_pages (
id bigint auto_increment
, code varchar(30) not null
, name varchar(255) not null
, application_id bigint
, created_on datetime
, last_updated_on datetime
, created_by bigint
, last_updated_by bigint
, primary key ( id )
, foreign key ( application_id ) references web_applications ( id )
);
create table web_regions (
id bigint auto_increment
, name varchar(255) not null
, region_type varchar(30) not null
, sequence_id int not null
, page_id bigint
, parent_region_id bigint
, source_type varchar(30)
, source_table_or_query varchar(4000)
, created_on datetime
, last_updated_on datetime
, created_by bigint
, last_updated_by bigint
, primary key ( id )
, foreign key ( page_id ) references web_pages ( id )
, foreign key ( parent_region_id ) references web_regions ( id )
);
等等……这些表包含页面布局的数据。
我还有一个控制器,它基本上从上面提到的表中提取数据。数据拉取将决定 Spring Boot 应用中页面/视图的布局。
回到上面的示例,我在 web_applications 表中有一条记录用于 HR,在 web_pages 中有一条记录用于 EMPLOYEES。然后我有 EMPLOYEES 页面的区域记录,总而言之,它就像一个显示员工数据的表格。现在假设我在 web_page 表中为单个 EMPLOYEE 提供了另一条记录。将 EMPLOYEES 页面视为报告页面(带有指向 EMPLOYEE 页面的链接),将 EMPLOYEE 页面视为 CRUD 页面。
现在,当运行 spring boot web 应用程序时,url 将类似于:
https://localhost/f?p=HR:EMPLOYEES ::
然后将显示适当的布局。单击一行将基本上调用相同的 Spring Boot 页面 f?p=HR:EMPLOYEE:ID:1 但现在将显示不同的布局。
现在进入需求。所以基本上 HR 是这个 web 应用程序的一个应用程序(不是 Spring Boot)。假设我想为 ex 构建另一个应用程序:带有 CUSTOMERS、CUSTOMER、PRODUCTS、PRODUCT 页面的 SALES。同样,这些将在表 web_applications (SALES)、web_pages (CUSTOMERS、CUSTOMER、PRODUCTS 和 PRODUCT) 中有相应的记录。
所以现在我们在这个工具中有 2 个应用程序。具有以下 URL 的 HR 和 SALES;
https://localhost/f?p=SALES :::
我要做的是对https://localhost/f?p=HR :::进行单独的身份验证,对https://localhost/f?p=SALES :::进行另一个身份验证
但在 Spring Boot 看来,这只是一个单一的应用程序。Spring Boot 安全性是否支持单个应用程序中的多个身份验证/会话?
解决方案
f 是数据库中的一个函数,其中 p 表示在 APEX 中构建的相关应用程序。每个应用程序都有自己的一组安全设置,其中包括身份验证方法。
开箱即用,每个应用程序都被认为是独立的,如果您导航到不同的应用程序,则需要再次进行身份验证。我相信这是通过 cookie 和数据库行的组合在内部进行管理的。
如果您想模块化您的应用程序,那么如果它们是一个使用工作区共享的应用程序,则可以让它们全部运行 http://www.grassroots-oracle.com/2019/01/oracle-apex-application-session-sharing .html
我不确定什么是“冲刺启动”。
推荐阅读
- javascript - 为什么将 gl.texImage2D 中的格式设置为 gl.LUMINANCE 而不是 gl.RGB 会使画布上的 blob 文件大小仅小约 5%?
- log4net - 是否有 Microsoft.Extensions.Logging.ILogger 支持的 log4net.ILog 实现?
- javascript - 如何在 Angular 中使用 zone.js?
- html - 如何仅隐藏移动设备或移动视图的 div 类文本?
- rgb - 旋转时得到黑白图像?
- apache-spark - 这个 Hive 查询有问题吗?
- azure - 如何删除文本文件中引号内而不是行尾的 \r\n 换行符
- spring-boot - HttpMediaTypeNotAcceptableException:在异步模式下而不是在同步模式下找不到可接受的表示
- loops - 去掉PDF密码保护,知道密码WINDOWS
- php - 如何在 X 时间后只发送一次电子邮件