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

网站开发用C网站打不开dns修改

网站开发用C,网站打不开dns修改,淘客网站+wordpress,lnmp wordpress 树莓派springsecurity5和springsecurity6如何要实现多种登录方式#xff0c;自定义登录方式都是一样的操作步骤#xff0c;主要有四个步骤。 一、自定义登录用户实体实现springsecurity中的UserDetails接口 二、自定义登录用户实现类实现springsecurity中的UserDetailsService接口 …springsecurity5和springsecurity6如何要实现多种登录方式自定义登录方式都是一样的操作步骤主要有四个步骤。 一、自定义登录用户实体实现springsecurity中的UserDetails接口 二、自定义登录用户实现类实现springsecurity中的UserDetailsService接口 三、自定义登录用户authentic验证器继承springsecurity中的AbstractAuthenticationToken抽象类 四、自定义登录用户provider验证管理器实现springsecurity中的AuthenticationProvider接口 一、springsecurity5.7.x配置 package com.school.information.config;import com.school.information.core.security.filter.JwtAuthenticationTokenFilter; import com.school.information.core.security.handler.AccessDeniedHandlerImpl; import com.school.information.core.security.handler.AuthenticationEntryPointImpl; import com.school.information.core.security.provider.WechatAppUserAuthenticationProvider; import com.school.information.core.service.CustomPasswordService; import com.school.information.core.service.SecurityUserServiceImpl; import com.school.information.core.service.WechatAppUserServiceImpl; import org.springframework.context.annotation.Bean; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.ProviderManager; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.util.matcher.RequestMatcher;import javax.annotation.Resource; import java.util.Arrays;/** SecuritConfig配置类*/ EnableWebSecurity EnableMethodSecurity // 开启注解授权功能 public class SecurityConfig {Resourceprivate JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;Resourceprivate SecurityUserServiceImpl userDetailsService;Resourceprivate WechatAppUserServiceImpl wechatAppUserService;/*** 认证失败处理器*/Resourceprivate AuthenticationEntryPointImpl authenticationEntryPoint;Resourceprivate AccessDeniedHandlerImpl accessDeniedHandler;Resourceprivate RequestMatcher[] requestMatchers;Beanpublic SecurityFilterChain filterChain(HttpSecurity http) throws Exception {http// 关闭csrf 因为不使用session.csrf().disable()// 禁用HTTP响应标头.headers().frameOptions().disable().and()//不通过Session获取SecurityContext 基于token所以不需要session.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()// 过滤请求.authorizeHttpRequests(authorize - authorize.requestMatchers(requestMatchers).permitAll().anyRequest().authenticated());//对于登录login 注册register 验证码captchaImage 无需拦截 直接访问 // .antMatchers(/, /token/captcha).permitAll() // // 静态资源可匿名访问 // .antMatchers(HttpMethod.GET, /, /*.html, /**/*.html, /**/*.css, /**/*.js, /profile/**).permitAll() // .antMatchers(/swagger-ui.html, /swagger-resources/**, /webjars/**, /*/api-docs, /druid/**).permitAll()// 除上面外的所有请求全部需要鉴权认证 // .anyRequest().authenticated();// 添加JWT filterhttp.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);// 认证失败处理类http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).accessDeniedHandler(accessDeniedHandler);// SpringSecurity设置允许跨域http.cors().disable();return http.build();}/*** 静态文件放行*/Beanpublic WebSecurityCustomizer webSecurityCustomizer() {return (web) - web.ignoring().antMatchers(/staic/**, /web/**);}Beanpublic PasswordEncoder passwordEncoder() {return new CustomPasswordService();}/*** 设置默认认证提供 用户名密码登录*/Beanpublic DaoAuthenticationProvider daoAuthenticationProvider() {final DaoAuthenticationProvider authenticationProvider new DaoAuthenticationProvider();authenticationProvider.setUserDetailsService(userDetailsService);authenticationProvider.setPasswordEncoder(passwordEncoder());return authenticationProvider;}/*** 设置小程序的登录验证方式 openid验证登录 没有密码** return*/Beanpublic WechatAppUserAuthenticationProvider daoWechatAppUserAuthenticationProvider() {final WechatAppUserAuthenticationProvider wechatAppUserAuthenticationProvider new WechatAppUserAuthenticationProvider();wechatAppUserAuthenticationProvider.setUserDetailsService(wechatAppUserService);return wechatAppUserAuthenticationProvider;}// 获取AuthenticationManager认证管理器登录时认证使用。 默认UsernamePasswordAuthenticationToken // Bean // public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { // return authenticationConfiguration.getAuthenticationManager(); // }/*** 对于默认的认证管理器 UsernamePasswordAuthenticationToken 直接使用上方的注释掉的代码即可* 如果项目中需要多个不同的认证管理器需要使用下方的代码将不同的认证管理器交由providerManager去管理** return* throws Exception*/Beanpublic AuthenticationManager authenticationManager() throws Exception {ProviderManager authenticationManager new ProviderManager(Arrays.asList(daoAuthenticationProvider(), daoWechatAppUserAuthenticationProvider()));return authenticationManager;}}二、springsecurity6.x配置文件 package com.school.information.config;import com.school.information.core.security.filter.JwtAuthenticationTokenFilter; import com.school.information.core.security.handler.AccessDeniedHandlerImpl; import com.school.information.core.security.handler.AuthenticationEntryPointImpl; import com.school.information.core.security.provider.WechatAppUserAuthenticationProvider; import com.school.information.core.service.CustomPasswordService; import com.school.information.core.service.SecurityUserServiceImpl; import com.school.information.core.service.WechatAppUserServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.ProviderManager; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.util.matcher.RequestMatcher;import java.util.Arrays;/** SecuritConfig配置类*/ Configuration EnableWebSecurity EnableMethodSecurity // 开启注解授权功能 RequiredArgsConstructor public class SecurityConfig {private final JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;private final SecurityUserServiceImpl userDetailsService;private final WechatAppUserServiceImpl wechatAppUserService;/*** 认证失败处理器*/private final AuthenticationEntryPointImpl authenticationEntryPoint;private final AccessDeniedHandlerImpl accessDeniedHandler;private final RequestMatcher[] requestMatchers;Beanpublic SecurityFilterChain filterChain(HttpSecurity http) throws Exception {// 关闭csrf 因为不使用sessionhttp.csrf(csrf - csrf.disable());// 禁用HTTP响应标头http.headers(headers - headers.frameOptions(frameOptionsConfig - frameOptionsConfig.disable()));//不通过Session获取SecurityContext 基于token所以不需要sessionhttp.sessionManagement(sessionManagement - sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS));// 过滤请求http.authorizeHttpRequests(authorize - authorize.requestMatchers(requestMatchers).permitAll().anyRequest().authenticated());//对于登录login 注册register 验证码captchaImage 无需拦截 直接访问 // .antMatchers(/, /token/captcha).permitAll() // // 静态资源可匿名访问 // .antMatchers(HttpMethod.GET, /, /*.html, /**/*.html, /**/*.css, /**/*.js, /profile/**).permitAll() // .antMatchers(/swagger-ui.html, /swagger-resources/**, /webjars/**, /*/api-docs, /druid/**).permitAll()// 除上面外的所有请求全部需要鉴权认证 // .anyRequest().authenticated();// 添加JWT filterhttp.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);// 认证失败处理类http.exceptionHandling(exceptionHandlingConfigurer - exceptionHandlingConfigurer.authenticationEntryPoint(authenticationEntryPoint).accessDeniedHandler(accessDeniedHandler));// SpringSecurity设置允许跨域http.cors(cors - cors.disable());return http.build();}/*** 静态文件放行*/Beanpublic WebSecurityCustomizer webSecurityCustomizer() {return (web) - web.ignoring().requestMatchers(/staic/**, /web/**);}Beanpublic PasswordEncoder passwordEncoder() {return new CustomPasswordService();}/*** 设置默认认证提供 用户名密码登录*/Beanpublic DaoAuthenticationProvider daoAuthenticationProvider() {final DaoAuthenticationProvider authenticationProvider new DaoAuthenticationProvider();authenticationProvider.setUserDetailsService(userDetailsService);authenticationProvider.setPasswordEncoder(passwordEncoder());return authenticationProvider;}/*** 设置小程序的登录验证方式 openid验证登录 没有密码** return*/Beanpublic WechatAppUserAuthenticationProvider daoWechatAppUserAuthenticationProvider() {final WechatAppUserAuthenticationProvider wechatAppUserAuthenticationProvider new WechatAppUserAuthenticationProvider();wechatAppUserAuthenticationProvider.setUserDetailsService(wechatAppUserService);return wechatAppUserAuthenticationProvider;}// 获取AuthenticationManager认证管理器登录时认证使用。 默认UsernamePasswordAuthenticationToken // Bean // public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { // return authenticationConfiguration.getAuthenticationManager(); // }/*** 如果项目中需要多个不同的认证管理器需要使用下方的代码将不同的认证管理器交由providerManager去管理** return* throws Exception*/Beanpublic AuthenticationManager authenticationManager() throws Exception {ProviderManager authenticationManager new ProviderManager(Arrays.asList(daoAuthenticationProvider(), daoWechatAppUserAuthenticationProvider()));return authenticationManager;}}
http://wiki.neutronadmin.com/news/26156/

相关文章:

  • 门户网站排行榜免费照片的网站模板
  • 网站建设外包公司怎么样合肥网站建设托管
  • 汕头市做网站青岛seo网站排名优化
  • 临沂自助建站软件网站建设措施
  • 网页设计网站建设扁平式网站建设
  • 专业网站制作公司咨询wordpress 图片浏览
  • 上街区做网站电影网站开发api
  • 南昌做公司网站互联网官方网站
  • 房产类网站建设企业培训考试系统
  • 网站改版业务云南高端网站建设公司
  • 东阳网站建设有哪些wordpress地图生成
  • 网站首页有哪些内容企业手机网站建设定制
  • 高港网站建设肥城网站建设哪家好
  • 怎么做淘客网站极简风格 网站
  • 请人做网站需要多少钱网站登录怎么保存用户名密码
  • 服装网站建设策划书3000字永康公司网站建设
  • 网站改了关键词关于做网站流程
  • 推荐昆明做网站建设番禺建网站价格
  • 长沙网站seo收费标准wordpress怎么弄中文
  • 做牛津纺衬衫的网站免费企业网站php源码
  • 地方门户网站模版网站开发方案怎么写
  • 设计网站汇总wordpress与typecho
  • 承德网站建设报价小程序微盟
  • 优美网站源码前端做网站都要做哪些
  • 深圳线运营是网站建设推网怎么制作
  • 常州个人做网站河南工程学院网站建设
  • 网站不想被百度抓取asp网站开发 pdf
  • 唐山乾正建设工程材料检测公司网站哈尔滨网站建设费用
  • 中文域名.网站泉州手机端建站模板
  • 如何找到做网站的客户浙江网站备案流程