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

在家里怎样做网站wordpress公司主页

在家里怎样做网站,wordpress公司主页,莱州网站建设制作,网站没备案可以上线吗WebAuthn是无密码身份验证技术,解决了密码泄露的风险,主流的浏览器都支持。有很多开源的类库实现了WebAuthn规范,Java下流行的类库有:webauthn4jjava-webauthn-serververtx-authSpring Security官方暂时未支持WebAuthn&#xff0c…

WebAuthn是无密码身份验证技术,解决了密码泄露的风险,主流的浏览器都支持。有很多开源的类库实现了WebAuthn规范,Java下流行的类库有:

  • webauthn4j

  • java-webauthn-server

  • vertx-auth

Spring Security官方暂时未支持WebAuthn,可以用webauthn4j的webauthn4j-spring-security项目,它将webauthn4j和Spring Security打通,项目还处于开发阶段,设计上可能还会调整。但我们可以通过项目里的demo,很好的学习怎么实现WebAuthn。简单介绍一下webauthn4j-spring-security中例子的打开方式。

demo启动流程

  1. 克隆项目

git clone git@github.com:webauthn4j/webauthn4j-spring-security.git
  1. 打包前端资源

cd webauthn4j-spring-security/samples/lib/spa-angular-client
npm install

PS: 这里可能会碰到打包异常,是@angular/cdk包版本和其他模块版本冲突了,将@angular/cdk改成“13.3.9”就能正常打包

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: sample-angular-client@0.0.0
npm ERR! Found: @angular/common@13.3.12
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^13.3.11" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^15.0.0 || ^16.0.0" from @angular/cdk@15.2.1
npm ERR! node_modules/@angular/cdk
npm ERR!   @angular/cdk@"^15.1.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
  1. 启动项目

cd webauthn4j-spring-security
./gradlew build
./gradlew samples:spa:bootRun
  1. 查看登录页

  1. 访问:http://localhost:8080/,就会自动跳转到[http://localhost:8080/angular/login](http://localhost:8080/angular/login)

HttpSecurity核心配置

@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {// WebAuthn Loginhttp.apply(WebAuthnLoginConfigurer.webAuthnLogin()).usernameParameter("username").passwordParameter("password").credentialIdParameter("credentialId").clientDataJSONParameter("clientDataJSON").authenticatorDataParameter("authenticatorData").signatureParameter("signature").clientExtensionsJSONParameter("clientExtensionsJSON").loginProcessingUrl("/login").attestationOptionsEndpoint().rp().name("WebAuthn4J Spring Security Sample").and().pubKeyCredParams(new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS256), // Windows Hellonew PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256) // FIDO U2F Key, etc).extensions().credProps(true).and().assertionOptionsEndpoint().and().successHandler(authenticationSuccessHandler).failureHandler(authenticationFailureHandler).and().authenticationManager(authenticationManager);http.headers(headers -> {// 'publickey-credentials-get *' allows getting WebAuthn credentials to all nested browsing contexts (iframes) regardless of their origin.headers.permissionsPolicy(config -> config.policy("publickey-credentials-get *"));// Disable "X-Frame-Options" to allow cross-origin iframe accessheaders.frameOptions().disable();});// Logouthttp.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);// Authorizationhttp.authorizeRequests().mvcMatchers("/").permitAll().mvcMatchers("/static/**").permitAll().mvcMatchers("/angular/**").permitAll().mvcMatchers("/webjars/**").permitAll().mvcMatchers("/favicon.ico").permitAll().mvcMatchers("/api/auth/status").permitAll().mvcMatchers(HttpMethod.GET, "/login").permitAll().mvcMatchers(HttpMethod.POST, "/api/profile").permitAll().mvcMatchers("/health/**").permitAll().mvcMatchers("/info/**").permitAll().mvcMatchers("/h2-console/**").denyAll().mvcMatchers("/api/admin/**").access("hasRole('ADMIN_ROLE') and isAuthenticated()").anyRequest().access("@webAuthnSecurityExpression.isWebAuthnAuthenticated(authentication) || hasAuthority('SINGLE_FACTOR_AUTHN_ALLOWED')");http.sessionManagement().sessionAuthenticationFailureHandler(authenticationFailureHandler);http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).accessDeniedHandler(accessDeniedHandler);// As WebAuthn has its own CSRF protection mechanism (challenge), CSRF token is disabled herehttp.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());http.csrf().ignoringAntMatchers("/webauthn/**");return http.build();
}

这个方法将SpringSecurity需要的配置基本都说清楚了,除了#1、#2跟WebAuthn直接相关,其他几点都是SpringSecurity常规配置。

  1. 添加了自定义的WebAuthnLoginConfigurer描述登录页面的URL、字段名等信息

  1. 通过pubKeyCredParams描述服务器可接受的公钥类型的对象数组。

  1. 设置自定义的authenticationManager、successHandler、failureHandler等

  1. 设置http的header

  1. 设置authorizeRequests控制权限

  1. 设置session和exceptionHandling

  1. 设置Csrf配置

引用

体验WebAuthn登录:https://webauthn.io/
http://www.yayakq.cn/news/206617/

相关文章:

  • 外贸服装网站模板科技信息期刊
  • 临沂网站建设对实体企业哪家网站设计好
  • 温岭做网站济南网约车公司
  • 辽宁招投标工程信息网濮阳做网站优化
  • 寻花问柳专注做一家男人爱的网站照片组合拼图
  • 网站建设的价做网站大图素材
  • 阿里云备案网站建设方案书案例长沙门户网站建设
  • 网站开发需要什么基础知识常见的网站建设技术
  • 深圳福田区住房和建设局网站不收费的网站有哪些
  • mysql做网站怎么查看数据域名申请成功后怎么做网站
  • 北京网站制作设计与开发服务河南建设工程信息网 最权威平台中项网
  • 公司域名不变网站做变动小建筑公司简介模板
  • 河北大良网站建设销售网络建设应该如何着手
  • 做网站工资还没有文员高安卓 wordpress
  • 商城网站开发用什么框架logo设计公司 艺点意创
  • 做好评做销量的网站163手机移动网站
  • 建设网站公司联系方式迅驰互联网站建设网络推广怎么样
  • 怎么做网站的访问量禁用免费app网页
  • 免备案网站网站设计制作公司需要什么资质
  • 网站做系统下载做金融看哪些网站有哪些内容
  • 网站开发饼图样式第三方网站
  • 关键词优化网站排名wordpress模版 使用
  • 仿公众号网站嘉兴网站建设正规公司
  • 专业网站制作公司是如何处理一个优秀的网站的沈阳网站建设公司排名
  • 广州网站建设专注乐云seo5118站长工具箱
  • 网站清除黑链辽宁建设工程信息网查询系统
  • 深圳网站建设团队营销策略从哪几个方面分析
  • 惠州建网站公司口子网站怎么做
  • 长春建站优化加徽信xiala5效果好中国设计者联盟官网
  • 黑色系 网站山西省城乡住房建设厅网站