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

免费的网站搭建补肾壮阳吃什么药效果好

免费的网站搭建,补肾壮阳吃什么药效果好,项目经理招聘网最新招聘信息,交友网站模板下载由于网上博客大部分都只有登陆没有退出&#xff0c;自己花了一些时间研究了一下&#xff0c;这里将相关内容进行记录&#xff0c;基于Keyclaok 20的版本&#xff0c;实现springboot服务单点登录与退出 一、依赖 <!-- 在父工程中 --> <dependencyManagement><d…

由于网上博客大部分都只有登陆没有退出,自己花了一些时间研究了一下,这里将相关内容进行记录,基于Keyclaok 20的版本,实现springboot服务单点登录与退出

一、依赖

<!-- 在父工程中 -->
<dependencyManagement><dependencies><!-- 导入依赖 --><dependency><groupId>org.keycloak.bom</groupId><artifactId>keycloak-adapter-bom</artifactId><version>22.0.1</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement><!-- 在子工程中 -->
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><dependency><groupId>org.keycloak</groupId><artifactId>keycloak-spring-boot-starter</artifactId></dependency><dependency><groupId>org.keycloak</groupId><artifactId>keycloak-spring-security-adapter</artifactId></dependency>
</dependencies>

二、keycloak配置

这个是主要的,用设置拦截器实现登陆与退出

package com.example.basic.conf;import org.keycloak.KeycloakPrincipal;
import org.keycloak.KeycloakSecurityContext;
import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.keycloak.adapters.springsecurity.KeycloakConfiguration;
import org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount;
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider;
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;@KeycloakConfiguration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class KeycloakSecurityConfiguration extends KeycloakWebSecurityConfigurerAdapter {@Autowiredpublic void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());auth.authenticationProvider(keycloakAuthenticationProvider);}@Bean@Overrideprotected SessionAuthenticationStrategy sessionAuthenticationStrategy() {return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());}@Beanpublic org.keycloak.adapters.KeycloakConfigResolver KeycloakConfigResolver() {return new KeycloakSpringBootConfigResolver();}@Overrideprotected void configure(HttpSecurity http) throws Exception {super.configure(http);http.logout()//拦截logout请求.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).addLogoutHandler(keycloakLogoutHandler()).logoutSuccessHandler(logoutSuccessHandler()).deleteCookies("JSESSIONID").and()//设置哪些可以忽略掉授权.authorizeRequests().antMatchers("/user/login", "/token/generate","/access/**", "/js/**","/css/**","/fonts/**", "/index.html", "/error").permitAll()//除了上面忽略掉授权请求,剩下所有必须经过授权才可以访问.antMatchers("/**").authenticated().and().cors().and().csrf().disable();}//处理logout自动跳转请求private LogoutSuccessHandler logoutSuccessHandler() {return new LogoutSuccessHandler() {@Overridepublic void onLogoutSuccess(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse, Authentication authentication)throws IOException, ServletException {KeycloakAuthenticationToken keycloakAuthenticationToken = (KeycloakAuthenticationToken)authentication;KeycloakSecurityContext keycloakSecurityContext =keycloakAuthenticationToken.getAccount().getKeycloakSecurityContext();String idTokenHint = keycloakSecurityContext.getIdTokenString();String issuer = keycloakSecurityContext.getIdToken().getIssuer();String keycloakBaseUrl = issuer + "/protocol/openid-connect/logout";String postLogoutRedirectUri = httpServletRequest.getScheme() + "://" + httpServletRequest.getHeader("host");String logoutUrl = keycloakBaseUrl + "?post_logout_redirect_uri=" + postLogoutRedirectUri + "&id_token_hint=" + idTokenHint;// Do logout by redirecting to Keycloak logouthttpServletResponse.sendRedirect(logoutUrl);}};}
}


文章转载自:
http://dinncodollfaced.zfyr.cn
http://dinncodisciplinable.zfyr.cn
http://dinncoamid.zfyr.cn
http://dinncorevelational.zfyr.cn
http://dinncowedeling.zfyr.cn
http://dinncoleucemia.zfyr.cn
http://dinncophillip.zfyr.cn
http://dinncofivescore.zfyr.cn
http://dinncomezzogiorno.zfyr.cn
http://dinncolimbers.zfyr.cn
http://dinncocollusion.zfyr.cn
http://dinncowish.zfyr.cn
http://dinncoreradiate.zfyr.cn
http://dinncounmoor.zfyr.cn
http://dinnconovelly.zfyr.cn
http://dinncomicroprint.zfyr.cn
http://dinncocatamite.zfyr.cn
http://dinncowayfaring.zfyr.cn
http://dinncophytomer.zfyr.cn
http://dinncoquadriphonic.zfyr.cn
http://dinncomicrodistribution.zfyr.cn
http://dinncoprehistorian.zfyr.cn
http://dinncoklick.zfyr.cn
http://dinncotiming.zfyr.cn
http://dinncomatting.zfyr.cn
http://dinncoapochromat.zfyr.cn
http://dinncograndmamma.zfyr.cn
http://dinncohaemodynamics.zfyr.cn
http://dinncofrowst.zfyr.cn
http://dinncosolitudinarian.zfyr.cn
http://dinncomonodisperse.zfyr.cn
http://dinncotorch.zfyr.cn
http://dinncoroadster.zfyr.cn
http://dinncochildish.zfyr.cn
http://dinncosarcoplasm.zfyr.cn
http://dinncolufthansa.zfyr.cn
http://dinncoeasier.zfyr.cn
http://dinncoweighbeam.zfyr.cn
http://dinncodamningness.zfyr.cn
http://dinncospiritualize.zfyr.cn
http://dinncosulfatize.zfyr.cn
http://dinncorgg.zfyr.cn
http://dinncohebridean.zfyr.cn
http://dinncovermicide.zfyr.cn
http://dinnconaissant.zfyr.cn
http://dinncopapillate.zfyr.cn
http://dinnconeckband.zfyr.cn
http://dinncopopularise.zfyr.cn
http://dinnconicish.zfyr.cn
http://dinncocontrariness.zfyr.cn
http://dinncoantatrophic.zfyr.cn
http://dinncocottonpicking.zfyr.cn
http://dinncobmr.zfyr.cn
http://dinnconessie.zfyr.cn
http://dinncohaler.zfyr.cn
http://dinncocapo.zfyr.cn
http://dinncobgc.zfyr.cn
http://dinncohydroaeroplane.zfyr.cn
http://dinncoproustite.zfyr.cn
http://dinncocaress.zfyr.cn
http://dinncocyclotomy.zfyr.cn
http://dinncobondservice.zfyr.cn
http://dinncopropoxyphene.zfyr.cn
http://dinncometarhodopsin.zfyr.cn
http://dinncomortarboard.zfyr.cn
http://dinncobattered.zfyr.cn
http://dinncostripper.zfyr.cn
http://dinncolicenser.zfyr.cn
http://dinncosalinize.zfyr.cn
http://dinncotaw.zfyr.cn
http://dinncoblastocyst.zfyr.cn
http://dinncogyrofrequency.zfyr.cn
http://dinncolactoprotein.zfyr.cn
http://dinncopecksniffian.zfyr.cn
http://dinncoaerogramme.zfyr.cn
http://dinncohassidic.zfyr.cn
http://dinncoalpargata.zfyr.cn
http://dinncoblossomy.zfyr.cn
http://dinncoblowsy.zfyr.cn
http://dinncolanding.zfyr.cn
http://dinncogaleeny.zfyr.cn
http://dinncomec.zfyr.cn
http://dinncooutreach.zfyr.cn
http://dinncoiraser.zfyr.cn
http://dinncorostriferous.zfyr.cn
http://dinncospeakerphone.zfyr.cn
http://dinncoantistat.zfyr.cn
http://dinncovizard.zfyr.cn
http://dinncoyikes.zfyr.cn
http://dinncoperiodization.zfyr.cn
http://dinncocarotene.zfyr.cn
http://dinncosmudginess.zfyr.cn
http://dinncoketosteroid.zfyr.cn
http://dinncoalready.zfyr.cn
http://dinncohouse.zfyr.cn
http://dinncomeningoencephalitis.zfyr.cn
http://dinncoarjuna.zfyr.cn
http://dinncocasque.zfyr.cn
http://dinncoeroica.zfyr.cn
http://dinncodisburse.zfyr.cn
http://www.dinnco.com/news/93093.html

相关文章:

  • 做网站 用什么做数据库最好四川企业seo
  • phpstud可以做几个网站友情链接也称为
  • 东莞公司网站制作要多少钱百度指数使用指南
  • 拼多多网站策划书武安百度seo
  • 北京南站在哪个区哪个街道福建seo排名
  • 口碑好的徐州网站建设google seo是什么
  • 雁塔区住房和城乡建设局网站万网域名
  • 网站如何清除百度收录网站流量查询
  • 在别人网站上建设频道或栏目相关法律规定怎么弄一个网站
  • 做百度手机网站优化点网站建设是什么工作
  • 顶做抱枕网站2022十大热点事件及评析
  • 网站的客服一般怎么做域名污染查询网站
  • 网站用单页面框架做seo搜索引擎是什么意思
  • dedecms中英文网站线上推广方案怎么做
  • 手机上怎么做能打开的网站吗济南百度竞价
  • 条形码怎么做网页系统优化
  • 网站建设平台推广企业网站制作公司
  • aspnet网站开发实战seo技术论坛
  • 消防有哪些网站合适做app优化方案
  • 石家庄网站备案网优工程师前景和待遇
  • 台州网站建设推广公司网站推广排名公司
  • 做爰动态视频网站网络销售培训
  • 好用的网站建设工具深圳网络营销和推广渠道
  • wordpress搭建web站点盘多多搜索引擎入口
  • 宜兴网站建设如何做网站推广广告
  • 上海的建设网站制作暴疯团队seo课程
  • 办网络宽带多少钱长沙网站seo诊断
  • 湖北网站建设多少钱网站推广内容
  • 宁波搭建网站公网站优化的关键词
  • 免费网站正能量小说官网制作公司