目前无法从 Intellij 连接到在 ubuntu 上的 docker 容器上本地运行的 mySql。
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| tasklogs |
+--------------------+
+----------+-----------+------+
| DATABASE | HOST | USER |
+----------+-----------+------+
| tasklogs | localhost | dev |
| tasklogs | localhost | root |
+----------+-----------+------+
+-----------------------------------------------------------+
| Grants for dev@localhost |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO `dev`@`localhost` |
| GRANT ALL PRIVILEGES ON `tasklogs`.* TO `dev`@`localhost` |
+-----------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
docker ps …
我正在单个客户端托管应用程序(CLIENT)和我的spring boot 2应用程序(SERVER)之间实现相互身份验证.我理解步骤如下:
服务器生成密钥库和信任库.该密钥库被用于存储服务器的证书和私钥.该信任存储用于存储(从证书机构(CA)或受信任的客户端证书的证书)其它凭证.
一个企业社会责任是提高了,然后传递给CA的服务器 CA从CSR生成签名证书.这是安装在服务器密钥库中的.
当从客户端到服务器发出https请求时:
所以我有一些事情让我有点困惑......
security https spring-security spring-boot mutual-authentication
尝试从4.3.11升级到hibernate 5.2.9.目前使用的是hibernate native api.在pom.xml中添加依赖项后,运行单元测试时出现以下错误:
通过字段'sessionFactory'表示不满意的依赖; 嵌套异常是org.springframework.beans.factory.BeanCreationException:创建类路径资源[testApplicationContext.xml]中定义的名为'sessionFactory'的bean时出错:init方法的调用失败; 嵌套异常是org.hibernate.loader.MultipleBagFetchException:无法同时获取多个包
我有一个testApplicationContext.xml,其中包含以下内容:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="org.xxxx.xxxx.xxxx.model"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Run Code Online (Sandbox Code Playgroud)
我将sessionFactory和transactionManager从hibernate4更新为hibernate5.
pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.9.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
据我所知,错误消息暗示加载多个急切加载的集合时出现问题.但是,我从知道这个,使用Hibernate的相关注释和休眠支持新版本的这种使用情况.
有人可以帮忙吗?谢谢
我们有一个spring mvc rest api,利用spring security和hibernate到MySql db.
我们配置了一些角色.例如:
标准用户:ROLEA
超级用户:ROLEB
目前,为了确保经过身份验证的用户有权访问/更新某个资源,我们执行以下操作:
确定当前经过身份验证的用户:
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String activeLogin = authentication.getName();
Run Code Online (Sandbox Code Playgroud)
确定与他们尝试访问的实体关联的登录信息:
String loginAssociatedToRequestedEntity = fooService.getEntityA(EntityAId).getEntityB().getEntityC().getLogin();
Run Code Online (Sandbox Code Playgroud)
将与给定资源关联的用户与活动登录进行比较:
if (!loginAssociatedToRequestedEntity.equals(activeLogin)) {
throw new ForbiddenAccessException();
}
Run Code Online (Sandbox Code Playgroud)
我有很多问题,其中一些问题包括:
我考虑过以下可能的选项:
所以我的问题是,是否有最佳做法是确保经过身份验证的用户有权访问某个资源,即阻止他们访问同一角色的其他用户的资源.
如果你能指出一个非常值得赞赏的具体例子(github).
TIA.
在Cloud Foundry中,我对其进行了配置,以便将客户端证书转发到我的 Spring Boot 应用程序。
证书放置在x-forwarded-client-cert标头中,Spring Boot 应用程序读取此?,并检查 CN 是否已列入白名单并发送适当的响应。不幸的是,我无法通过测试复制这种行为。我不断得到(在调试输出中):
“请求中找不到客户端证书”
我正在使用REST Assured,我的测试如下所示:
String cert = StreamUtils.copyToString(
new ClassPathResource("certs/client/client_mod.crt").getInputStream(), Charset.defaultCharset());
cert = cert.replace("\r\n", "").replace("\n", "");
given()
.spec(spec)
.header("x-forwarded-client-cert", cert)
.when()
.get(HealthResource.BASE_URL + "/ip-reverse-lookup")
.then()
.statusCode(HttpStatus.OK.value());
Run Code Online (Sandbox Code Playgroud)
其基本 uri 是http://localhost. 客户端证书 "-----BEGIN CERTIFICATE-----"和"-----END CERTIFICATE-----"已被删除,换行符也被删除(如上面的代码所示)。
在我的 application.yml 中我有这个:
server:
ssl:
enabled: false
key-store:
key-store-password:
trust-store:
trust-store-password:
client-auth: need
Run Code Online (Sandbox Code Playgroud)
configure扩展类的方法如下WebSecurityConfigurerAdapter所示:
http
.x509()
.subjectPrincipalRegex("CN=(.*?)(?:,|$)")
.userDetailsService(customUserDetailsService)
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.csrf().disable();
Run Code Online (Sandbox Code Playgroud)
任何帮助/建议将不胜感激。 …
spring-security cloud-foundry spring-boot mutual-authentication
我有这个log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="JsonAppender" target="SYSTEM_OUT">
<JsonTemplateLayout eventTemplateUri="classpath:EcsLayout.json" />
</Console>
</Appenders>
<Loggers>
<Logger name="JsonLogger" level="INFO" additivity="false">
<AppenderRef ref="JsonAppender"/>
</Logger>
<Root level="info">
<AppenderRef ref="JsonAppender"/>
</Root>
</Loggers>
</Configuration>
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我有一个日志记录语句,例如:
HashMap logMap = new HashMap<>();
logMap.put("appId", "123456789");
logMap.put("action", "Received request");
logger.info(new ObjectMessage(logMap));
Run Code Online (Sandbox Code Playgroud)
在我的日志中我得到这个:
{
"@timestamp": "2022-02-02T10:52:56.100Z",
"ecs.version": "1.2.0",
"log.level": "INFO",
"message": "{appId=123456789, action=Received request}",
"process.thread.name": "main",
"log.logger": "org.xxxx.App"
}
Run Code Online (Sandbox Code Playgroud)
没关系,但我希望message采用 json 格式,所以希望:
"message": {
"appId": "123456789",
"action": "Received request"
}
Run Code Online (Sandbox Code Playgroud)
我知道使用时JsonLayout必须指定objectMessageAsJsonObject="true",但怀疑使用时有点微妙JsonTemplateLayout …
首次向应用商店提交应用.
根据iTunes Connect:
"需要一个模拟账户才能使用该应用的所有功能."
...这是我的应用程序的情况.
我想让这个模拟账户指向dev api,但其他一切都指向prod api.
我的应用程序是基于Cordova的,并且api url通过常量注入到相关的http服务中.我正在使用grunt并拥有像grunt prod/grunt dev等命令,利用ngconstant为运行的命令生成一个带有api url的模块,即dev api url常量的grunt dev.
我考虑过硬编码用户名和重写/重新定义网址常量,因为它似乎有点可能,尽管不推荐(作为常量和全部). - 无论如何,我无法让它发挥作用.
所以...
有谁知道怎么解决这个问题?
如果应用程序最初是使用dev api url提交的,则审核然后接受,然后重新提交prod api~是否需要进行另一次完整审核?