当前位置: 首页 > news >正文

springmvc-springsecurity-redhat keycloak SAML2 xml实现

环境准备:

jdk17

redhat keycloak 24

spring security 6

参照文档:

红帽KeyCloak:Red Hat build of Keycloak | Red Hat Product Documentation

入门指南:入门指南 | Red Hat Product Documentation

服务器管理指南:服务器管理指南 | Red Hat Product Documentation

Redhat Keycloak:

本地启动:

\rhbk-24.0.7\bin\kc.bat start-dev --http-port 8180

管理控制台的URL:http://localhost:8180/admin

账户控制台的URL:http://localhost:8180/realms/{myrealm}/account

Spring MVC:

<mvc:redirect-view-controller path="/aml01/saml2/sso_login"
        redirect-url="/saml2/authenticate/saml-app" />

saml-app:同security中的registration-id

Spring security:

POM引入包:

<dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-saml2-service-provider</artifactId>
</dependency>
	<http auto-config="true"><intercept-url pattern="/**" access="authenticated"/><saml2-loginauthentication-success-handler-ref="samlAuthenticationSuccessHandler"
/><saml2-logout /></http><relying-party-registrations><relying-party-registration registration-id="saml-app"entity-id="saml-app"assertion-consumer-service-location="http://localhost:8080/login/saml2/sso/{registrationId}"assertion-consumer-service-binding="POST"single-logout-service-location="http://localhost:8080/logout/saml2/slo"single-logout-service-response-location="http://localhost:8080/logout/saml2/slo"asserting-party-id="saml-xml"><signing-credential certificate-location="classpath:credentials/rp-certificate.crt"private-key-location="classpath:credentials/rp-private.key"/></relying-party-registration><asserting-party asserting-party-id="saml-xml"entity-id="http://localhost:8180/realms/demo"single-sign-on-service-location="http://localhost:8180/realms/demo/protocol/saml"single-sign-on-service-binding="POST"signing-algorithms="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"single-logout-service-location="http://localhost:8180/realms/demo/protocol/saml"single-logout-service-binding="POST"single-logout-service-response-location="http://localhost:8180/realms/demo/protocol/saml"want-authn-requests-signed="true"><verification-credential private-key-location="classpath:credentials/rp-private.key"certificate-location="classpath:credentials/idp-certificate.crt"/><encryption-credential private-key-location="classpath:credentials/rp-private.key"certificate-location="classpath:credentials/idp-certificate.crt"/></asserting-party></relying-party-registrations>

这个URL「assertion-consumer-service-location="{baseUrl}/login/saml2/sso/{registrationId}"」和keycloak的client的Valid redirect URIs相同

Valid redirect URIs:localhost:8080/login/saml2/sso/saml-app

证明书和key做成:
openssl req -newkey rsa:2048 -nodes -keyout rp-private.key -x509 -days 365 -out rp-certificate.crt

rp-certificate.crt导入keycloak的Clients -> client details ->keys ->import key

代码:

包结构:

└─pom.xml
│  
└─src
    ├─main
    │  ├─java
    │  │  └─example
    │  │          IndexController.java
    │  │          KeyLoader.java
    │  │          WebConfiguration.java
    │  │          
    │  ├─resources
    │  │  │  logback.xml
    │  │  │  
    │  │  └─credentials
    │  │          idp-certificate.crt
    │  │          rp-certificate.crt
    │  │          rp-private.key
    │  │          
    │  └─webapp
    │      ├─META-INF
    │      │      MANIFEST.MF
    │      │      
    │      ├─resources
    │      │  ├─css
    │      │  │      bootstrap-responsive.css
    │      │  │      bootstrap.css
    │      │  │      
    │      │  └─img
    │      │          favicon.ico
    │      │          logo.png
    │      │          
    │      └─WEB-INF
    │          │  jboss-web.xml
    │          │  spring-servlet.xml
    │          │  web.xml
    │          │  
    │          ├─spring
    │          │      security.xml
    │          │      
    │          └─templates
    │                  index.html
    │                  
    └─test
        └─java

pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.springframework.security</groupId><artifactId>keycloak-integration-demo</artifactId><version>1.0-SNAPSHOT</version><packaging>war</packaging><properties><spring.version>6.2.1</spring.version> <!-- Adjust to your Spring BOM version --><junit.version>5.10.3</junit.version></properties><dependencies><!-- OpenSAML Dependencies --><dependency><groupId>org.opensaml</groupId><artifactId>opensaml-saml-api</artifactId><version>4.1.1</version></dependency><dependency><groupId>org.opensaml</groupId><artifactId>opensaml-saml-impl</artifactId><version>4.1.1</version></dependency><!-- Spring Dependencies --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>6.1.3</version></dependency><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-config</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-web</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-saml2-service-provider</artifactId><version>${spring.version}</version></dependency><!-- Thymeleaf Dependencies --><dependency><groupId>org.thymeleaf</groupId><artifactId>thymeleaf-spring6</artifactId><version>3.1.2.RELEASE</version></dependency><dependency><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-springsecurity6</artifactId><version>3.1.2.RELEASE</version></dependency><!-- Servlet API --><dependency><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>6.1.0</version><scope>provided</scope></dependency><!-- Testing Dependencies --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>${junit.version}</version><scope>test</scope></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-engine</artifactId><version>${junit.version}</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>6.1.13</version><scope>test</scope></dependency><dependency><groupId>org.assertj</groupId><artifactId>assertj-core</artifactId><version>3.26.3</version><scope>test</scope></dependency><dependency><groupId>org.htmlunit</groupId><artifactId>htmlunit</artifactId><version>4.3.0</version><scope>test</scope></dependency></dependencies><build><finalName>aml-web</finalName><plugins><!-- Maven War Plugin --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.3.2</version></plugin><!-- Maven Surefire Plugin --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>3.0.0-M7</version><configuration><includes><include>**/*Tests.java</include></includes></configuration></plugin><!-- Other plugins like Gretty and Integrtest would need to be replaced with their Maven equivalents or configured differently --></plugins></build><repositories><repository><id>central</id><url>https://repo.maven.apache.org/maven2</url></repository><repository><id>spring-snapshots</id><url>https://repo.spring.io/snapshot</url><snapshots><enabled>true</enabled></snapshots></repository><repository><id>spring-milestones</id><url>https://repo.spring.io/milestone</url></repository><repository><id>shibboleth-releases</id><url>https://build.shibboleth.net/nexus/content/repositories/releases</url></repository></repositories>
</project>

security.xml:

<b:beans xmlns="http://www.springframework.org/schema/security"xmlns:b="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:util="http://www.springframework.org/schema/util"xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"><http auto-config="true"><intercept-url pattern="/**" access="authenticated"/><saml2-loginauthentication-success-handler-ref="samlAuthenticationSuccessHandler"
/><saml2-logout /></http><!-- 認証成功した場合画面遷移Handler --><b:bean id="samlAuthenticationSuccessHandler"class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler"><b:property name="targetUrlParameter" value="redirectTo" /><b:property name="alwaysUseDefaultTargetUrl" value="true" /><b:property name="defaultTargetUrl" value="/test" /></b:bean><user-service><user name="user" password="{noop}password" authorities="ROLE_USER" /></user-service><relying-party-registrations><relying-party-registration registration-id="saml-app"entity-id="saml-app"assertion-consumer-service-location="http://localhost:8080/login/saml2/sso/{registrationId}"assertion-consumer-service-binding="POST"single-logout-service-location="http://localhost:8080/logout/saml2/slo"single-logout-service-response-location="http://localhost:8080/logout/saml2/slo"asserting-party-id="saml-xml"><signing-credential certificate-location="classpath:credentials/rp-certificate.crt"private-key-location="classpath:credentials/rp-private.key"/></relying-party-registration><asserting-party asserting-party-id="saml-xml"entity-id="http://localhost:8180/realms/demo"single-sign-on-service-location="http://localhost:8180/realms/demo/protocol/saml"single-sign-on-service-binding="POST"signing-algorithms="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"single-logout-service-location="http://localhost:8180/realms/demo/protocol/saml"single-logout-service-binding="POST"single-logout-service-response-location="http://localhost:8180/realms/demo/protocol/saml"want-authn-requests-signed="true"><verification-credential private-key-location="classpath:credentials/rp-private.key"certificate-location="classpath:credentials/idp-certificate.crt"/><encryption-credential private-key-location="classpath:credentials/rp-private.key"certificate-location="classpath:credentials/idp-certificate.crt"/></asserting-party></relying-party-registrations> </b:beans>

spring-servlet.xml:

<!--~ Copyright 2022 the original author or authors.~~ Licensed under the Apache License, Version 2.0 (the "License");~ you may not use this file except in compliance with the License.~ You may obtain a copy of the License at~~      https://www.apache.org/licenses/LICENSE-2.0~~ Unless required by applicable law or agreed to in writing, software~ distributed under the License is distributed on an "AS IS" BASIS,~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.~ See the License for the specific language governing permissions and~ limitations under the License.--><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"><context:component-scan base-package="example"/></beans>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttps://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><!--- Location of the XML file that defines the root application context- Applied by ContextLoaderListener.--><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/spring/*.xml</param-value></context-param><filter><filter-name>springSecurityFilterChain</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class></filter><filter-mapping><filter-name>springSecurityFilterChain</filter-name><url-pattern>/*</url-pattern></filter-mapping><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><servlet><servlet-name>spring</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class></servlet><servlet-mapping><servlet-name>spring</servlet-name><url-pattern>/</url-pattern></servlet-mapping>
</web-app>

index.html:

<!--~ Copyright 2022 the original author or authors.~~ Licensed under the Apache License, Version 2.0 (the "License");~ you may not use this file except in compliance with the License.~ You may obtain a copy of the License at~~      https://www.apache.org/licenses/LICENSE-2.0~~ Unless required by applicable law or agreed to in writing, software~ distributed under the License is distributed on an "AS IS" BASIS,~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.~ See the License for the specific language governing permissions and~ limitations under the License.--><!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head><title>Spring Security - SAML 2.0 Login & Logout</title><meta charset="utf-8" /><style>span, dt {font-weight: bold;}</style><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container"><ul class="nav"><li class="nav-item"><form th:action="@{/logout}" method="post"><button class="btn btn-primary" id="rp_logout_button" type="submit">RP-initiated Logout</button></form></li></ul></div><main role="main" class="container"><h1 class="mt-5">SAML 2.0 Login & Single Logout with Spring Security</h1><p class="lead">You are successfully logged in as <span sec:authentication="name"></span></p><p class="lead">You're email address is <span th:text="${emailAddress}"></span></p><h2 class="mt-2">All Your Attributes</h2><dl th:each="userAttribute : ${userAttributes}"><dt th:text="${userAttribute.key}"></dt><dd th:text="${userAttribute.value}"></dd></dl><h6>Visit the <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html5/#servlet-saml2" target="_blank">SAML 2.0 Login & Logout</a> documentation for more details.</h6></main>
</div>
</body>
</html>

logback.xml:

<configuration><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><encoder><pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern></encoder></appender><logger name="org.springframework.security" level="TRACE"/><root level="TRACE"><appender-ref ref="STDOUT" /></root></configuration>

credentials:

idp-certificate.crt  keycloak的idp RSA256 cetificate

rp-certificate.crt   上面生成

rp-private.key   上面生成

WebConfiguration.java:

/** Copyright 2022 the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      https://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package example;import java.util.List;import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect;
import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring6.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.expression.BeanFactoryResolver;
import org.springframework.security.web.method.annotation.AuthenticationPrincipalArgumentResolver;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer, ApplicationContextAware {private ApplicationContext context;@Overridepublic void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {AuthenticationPrincipalArgumentResolver principalArgumentResolver = new AuthenticationPrincipalArgumentResolver();principalArgumentResolver.setBeanResolver(new BeanFactoryResolver(this.context.getAutowireCapableBeanFactory()));resolvers.add(principalArgumentResolver);}@Overridepublic void setApplicationContext(ApplicationContext context) throws BeansException {this.context = context;}@Beanpublic SpringResourceTemplateResolver templateResolver() {SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();templateResolver.setApplicationContext(this.context);templateResolver.setPrefix("/WEB-INF/templates/");templateResolver.setSuffix(".html");templateResolver.setTemplateMode(TemplateMode.HTML);templateResolver.setCacheable(false);return templateResolver;}@Beanpublic SpringTemplateEngine templateEngine(SpringResourceTemplateResolver templateResolver) {SpringTemplateEngine templateEngine = new SpringTemplateEngine();templateEngine.setTemplateResolver(templateResolver);templateEngine.setEnableSpringELCompiler(true);templateEngine.addDialect(new SpringSecurityDialect());return templateEngine;}@Beanpublic ThymeleafViewResolver viewResolver(SpringTemplateEngine templateEngine) {ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();viewResolver.setTemplateEngine(templateEngine);return viewResolver;}}

IndexController.java:

/** Copyright 2022 the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      https://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package example;import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticatedPrincipal;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;@Controller
public class IndexController {private final RelyingPartyRegistrationRepository repository;public IndexController(RelyingPartyRegistrationRepository repository) {this.repository = repository;}@GetMapping("/test")public String index(Model model, @AuthenticationPrincipal Saml2AuthenticatedPrincipal principal) {String emailAddress = principal.getFirstAttribute("email");model.addAttribute("emailAddress", emailAddress);model.addAttribute("userAttributes", principal.getAttributes());return "index";}}

访问地址:

localhost:8080/test

相关文章:

springmvc-springsecurity-redhat keycloak SAML2 xml实现

环境准备&#xff1a; jdk17 redhat keycloak 24 spring security 6 参照文档&#xff1a; 红帽KeyCloak&#xff1a;Red Hat build of Keycloak | Red Hat Product Documentation 入门指南&#xff1a;入门指南 | Red Hat Product Documentation 服务器管理指南&#x…...

【K8S系列】Kubernetes Pod节点CrashLoopBackOff 状态及解决方案详解【已解决】

在 Kubernetes 中&#xff0c;Pod 的状态为 CrashLoopBackOff 表示某个容器在启动后崩溃&#xff0c;Kubernetes 尝试重启该容器&#xff0c;但由于持续崩溃&#xff0c;重启的间隔时间逐渐增加。下面将详细介绍 CrashLoopBackOff 状态的原因、解决方案及相关命令的输出解释。 …...

Linux: Shell编程入门

Shell 编程入门 1 ) Shell 概念 shell 是 在英语中 壳, 外壳的意思可以把它想象成嵌入在linux这样的操作系统里面的一个微型的编程语言不像C语言, C 或 Java 等编程语言那么完整&#xff0c;它可以帮我们完成很多自动化任务例如保存数据监测系统的负载等等&#xff0c;我们同样…...

python爬虫实战案例——抓取B站视频,不同清晰度抓取,实现音视频合并,超详细!(内含完整代码)

文章目录 1、任务目标2、网页分析3、代码编写 1、任务目标 目标网站&#xff1a;B站视频&#xff08;https://www.bilibili.com/video/BV1se41117WP/?vd_sourcee8e376ccbc5aa4cfd88e6a7917adfd1a&#xff09;&#xff0c;用于本文测验 要求&#xff1a;抓取该网址下的视频&…...

容灾与云计算概念

​​​​​​基础知识容灾备份——备份技术系统架构与备份网络方案-CSDN博客 SAN&#xff0c;是storage area network的简称&#xff0c;翻译过来就是存储区域网络。 顾名思义&#xff0c;SAN首先是一个网络&#xff0c;其次它是关于存储的&#xff0c;区域则是指服务器和存储资…...

基于 Python 的自然语言处理系列(44):Summarization(文本摘要)

在这一部分中&#xff0c;我们将探讨如何使用 Transformer 模型将长文档压缩为摘要&#xff0c;这个任务被称为文本摘要。文本摘要是 NLP 领域中最具挑战性的任务之一&#xff0c;因为它需要理解长篇文本并生成连贯的总结&#xff0c;捕捉文档中的核心主题。然而&#xff0c;当…...

RabbitMQ安装部署

安装Erlang 由于RabbitMQ是用Erlang语言编写的&#xff0c;所以在安装RabbitMQ之前需要安装Erlang 安装依赖 [rootpro-ex ~]yum install make gcc gcc-c build-essential openssl openssl-devel unixODBC unixODBC-devel kernel-devel m4 ncurses-devel设置Eralng的存储库 […...

智联招聘×Milvus:向量召回技术提升招聘匹配效率

01. 业务背景 在智联招聘平台&#xff0c;求职者和招聘者之间的高效匹配至关重要。招聘者可以发布职位寻找合适的人才&#xff0c;求职者则通过上传简历寻找合适的工作。在这种复杂的场景中&#xff0c;我们的核心目标是为双方提供精准的匹配结果。在搜索推荐场景下&#xff0c…...

unplugin-auto-import 库作用

unplugin-auto-import是一个 Vite、Webpack 和 Rollup 的插件。 一、自动导入模块 1. 减少手动导入 在 JavaScript 和 TypeScript 项目中&#xff0c;它可以自动检测并导入常用的模块和函数&#xff0c;无需手动在每个文件中进行导入操作。这大大减少了代码中的重复性导入语…...

【Multisim14.0正弦波>方波>三角波】2022-6-8

缘由有没有人会做啊Multisim14.0-其他-CSDN问答参考方波、三角波、正弦波信号产生 - 豆丁网...

vue3纯前端验证码示例

前言 验证码的用途&#xff1a;通过要求用户输入一串难以被机器自动识别的字符或图像&#xff0c;有效阻止恶意用户或脚本通过暴力破解方式尝试登录账户。验证码的分类&#xff1a;常见的验证码有短信、文本、图形等&#xff0c;安全度越高&#xff0c;依赖的插件或服务也越多…...

招聘程序员

全栈总监❤️golang❤️UI设计师 ☀️前端☀️Nodejs工☀️平面设计☀️PHP工 ☀️安卓❤️Flutter❤️运维☀️爬虫 公司福利&#xff1a; ☃️ 带薪年假、年终奖、13k-18k薪 &#x1f3e9; 内宿 2人/间或外宿可补助 &#x1f4b5; 转正绩效 ✨节日礼金&#xff1a;生日礼金…...

Android 判断手机放置的方向

#1024程序员节&#xff5c;征文# 文章目录 前言一、pandas是什么&#xff1f;二、使用步骤 1.引入库2.读入数据总结 需求 老板&#xff1a;我有个手持终端&#xff0c;不能让他倒了&#xff0c;当他倒或者倾斜的时候要发出报警&#xff1b; 程序猿&#xff1a;我这..... 老板…...

Telegram机器人的手机部署

目的 一直有读 epub 电子书的习惯&#xff0c;摘录段落复制下来段落很难看&#xff0c;把自己写的排版器的逻辑复制下来&#xff0c;写成了一个排版机器人所有发给机器人的文字&#xff0c;都会经过排版&#xff0c;后转发到读书频道 前提 本来最好方法是直接把机器人架在服…...

ffmpeg视频滤镜: 色温- colortemperature

滤镜简述 colortemperature 官网链接 》 FFmpeg Filters Documentation 这个滤镜可以调节图片的色温&#xff0c;色温值越大显得越冷&#xff0c;可以参考一下下图&#xff1a; 咱们装修的时候可能会用到&#xff0c;比如选择灯还有地板的颜色的时候&#xff0c;选暖色调还是…...

Django+Vue全栈开发项目入门(二)

Vue是一款用于构建用户界面的JavaScript渐进式框架&#xff0c;它基于标准HTML、CSS和JavaScript构建&#xff0c;并提供了一套声明式的、响应式的、组件化的编程模型&#xff0c;有助于高效地开发用户界面。 环境准备 安装Node.js&#xff1a;Vue项目的构建和运行依赖于Node…...

【ubuntu改源】

ubuntu改源 备份原始源查看ubuntu发行版本arm64 noble版本的源vim修改源更新系统软件源 备份原始源 sudo cp /etc/apt/sources.list /etc/apt/sources.list.disabled查看ubuntu发行版本 lsb_release -aarm64 noble版本的源 清华源 vim修改源 esc :1,$d # 删除所有# 默认注…...

SQLI LABS | Less-9 GET-Blind-Time based-Single Quotes

关注这个靶场的其它相关笔记&#xff1a;SQLI LABS —— 靶场笔记合集-CSDN博客 0x01&#xff1a;过关流程 输入下面的链接进入靶场&#xff08;如果你的地址和我不一样&#xff0c;按照你本地的环境来&#xff09;&#xff1a; http://localhost/sqli-labs/Less-9/ 靶场提示 …...

【小白学机器学习24】 用例子来比较:无偏估计和有偏估计

目录 1 关于无偏估计 1.1 无偏估计的定义 2 原始数据 2.1 假设我们是上帝&#xff0c;我们能创造一个总体/母体 population 2.2 按尽量随机取样的原则去取1个随机样本 sample1 3 一个关于无偏估计的理解 3.1 接着上面的总体和样本 sample1 3.2 左边的计算&#xff0c;期…...

C++在实际项目中的应用第二节:C++与网络编程

第五章&#xff1a;C在实际项目中的应用 第二节&#xff1a;C与网络编程 1. TCP/IP协议详解与C实现 TCP/IP&#xff08;传输控制协议/互联网协议&#xff09;是现代互联网通信的基础协议。理解 TCP/IP 协议对于开发网络应用至关重要。本节将详细介绍 TCP/IP 协议的工作原理以…...

【Python】 -- 趣味代码 - 小恐龙游戏

文章目录 文章目录 00 小恐龙游戏程序设计框架代码结构和功能游戏流程总结01 小恐龙游戏程序设计02 百度网盘地址00 小恐龙游戏程序设计框架 这段代码是一个基于 Pygame 的简易跑酷游戏的完整实现,玩家控制一个角色(龙)躲避障碍物(仙人掌和乌鸦)。以下是代码的详细介绍:…...

C++ 基础特性深度解析

目录 引言 一、命名空间&#xff08;namespace&#xff09; C 中的命名空间​ 与 C 语言的对比​ 二、缺省参数​ C 中的缺省参数​ 与 C 语言的对比​ 三、引用&#xff08;reference&#xff09;​ C 中的引用​ 与 C 语言的对比​ 四、inline&#xff08;内联函数…...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

RSS 2025|从说明书学习复杂机器人操作任务:NUS邵林团队提出全新机器人装配技能学习框架Manual2Skill

视觉语言模型&#xff08;Vision-Language Models, VLMs&#xff09;&#xff0c;为真实环境中的机器人操作任务提供了极具潜力的解决方案。 尽管 VLMs 取得了显著进展&#xff0c;机器人仍难以胜任复杂的长时程任务&#xff08;如家具装配&#xff09;&#xff0c;主要受限于人…...

第7篇:中间件全链路监控与 SQL 性能分析实践

7.1 章节导读 在构建数据库中间件的过程中&#xff0c;可观测性 和 性能分析 是保障系统稳定性与可维护性的核心能力。 特别是在复杂分布式场景中&#xff0c;必须做到&#xff1a; &#x1f50d; 追踪每一条 SQL 的生命周期&#xff08;从入口到数据库执行&#xff09;&#…...

Ubuntu Cursor升级成v1.0

0. 当前版本低 使用当前 Cursor v0.50时 GitHub Copilot Chat 打不开&#xff0c;快捷键也不好用&#xff0c;当看到 Cursor 升级后&#xff0c;还是蛮高兴的 1. 下载 Cursor 下载地址&#xff1a;https://www.cursor.com/cn/downloads 点击下载 Linux (x64) &#xff0c;…...

es6+和css3新增的特性有哪些

一&#xff1a;ECMAScript 新特性&#xff08;ES6&#xff09; ES6 (2015) - 革命性更新 1&#xff0c;记住的方法&#xff0c;从一个方法里面用到了哪些技术 1&#xff0c;let /const块级作用域声明2&#xff0c;**默认参数**&#xff1a;函数参数可以设置默认值。3&#x…...

渗透实战PortSwigger Labs指南:自定义标签XSS和SVG XSS利用

阻止除自定义标签之外的所有标签 先输入一些标签测试&#xff0c;说是全部标签都被禁了 除了自定义的 自定义<my-tag onmouseoveralert(xss)> <my-tag idx onfocusalert(document.cookie) tabindex1> onfocus 当元素获得焦点时&#xff08;如通过点击或键盘导航&…...

鸿蒙Navigation路由导航-基本使用介绍

1. Navigation介绍 Navigation组件是路由导航的根视图容器&#xff0c;一般作为Page页面的根容器使用&#xff0c;其内部默认包含了标题栏、内容区和工具栏&#xff0c;其中内容区默认首页显示导航内容&#xff08;Navigation的子组件&#xff09;或非首页显示&#xff08;Nav…...

C++中vector类型的介绍和使用

文章目录 一、vector 类型的简介1.1 基本介绍1.2 常见用法示例1.3 常见成员函数简表 二、vector 数据的插入2.1 push_back() —— 在尾部插入一个元素2.2 emplace_back() —— 在尾部“就地”构造对象2.3 insert() —— 在任意位置插入一个或多个元素2.4 emplace() —— 在任意…...