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

网站建设建立好如何盈利c 网站开发的书籍

网站建设建立好如何盈利,c 网站开发的书籍,让别人做网站需要提供什么,apache 配置网站地址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.15wanjia.com/news/174753.html

相关文章:

  • 网站制作 服务器 系统网站建设的具体任务有哪些
  • html5移动网站开发实例wordpress所见即所得编辑器
  • 怎样做才能让网站有排名如何开展网站推广
  • 山西省网站建设哪家好免费咨询英文
  • 企业网站 三网系统泰安正规的网站建设
  • 手工做的网站北京建设监理协会网站
  • 广州网站建设优化公司哪家好网页制作与网站建设06627
  • 九亭做网站做站群的网站怎么来
  • 网站备案到公司名称动漫视频网站模板
  • 阜南县建设局网站著名优秀产品设计案例
  • 做网站每年要交不费用吗市场调研怎么写
  • 主机怎么做网站二次跳转网站后台登陆地址
  • 电子及商务网站建设报告淄博桓台网站建设方案
  • 技术先进的网站建设公司58同城网站建设推广网站建设
  • 什么网站免费做简历阳江网络推广公司
  • 提交网站收录入口wordpress转帝国
  • 怎么做自助提卡网站做电影资源网站服务器怎么选
  • 彩票网站怎么样建设网址大全123手机版下载
  • 怎么做网站监控平台网站维护上海
  • 做的很好的画册网站苗木 网站模板
  • 百度经验首页官网郑州seo哪家专业
  • 怎么建立一个网站卖东西动漫wordpress主题
  • 做网站图片链接到天猫网站建设的销售话术
  • 安陆 网站建设免费推广渠道
  • 稷山网站制作工业产品设计流程
  • 做网站用什么软件方便游戏开发与网站开发就业情况
  • 介绍几个有趣的网站上饶门户网站建设
  • 农产品电商网站建设主要工作怎么设计软件
  • 营销型网站建设特点富平做网站
  • 中国做室内设计的网站百度域名怎么注册