oauth

Basic Authentication with a Guid token for REST api instead of username/password

我是研究僧i 提交于 2020-04-01 03:54:50
问题 Overview I am developing a mobile application using PhoneGap with REST API for the backend. The REST API won't be utilised by third-party developers, but will be application-specific, so there is no need for oAuth to be implemented. Hence, I am planning to use Basic Authentication where in the User enters their Username/password to access the API resources. All API communication will be on SSL. Basic Authentication with Token Instead of letting the application store the username/password and

Basic Authentication with a Guid token for REST api instead of username/password

折月煮酒 提交于 2020-04-01 03:53:32
问题 Overview I am developing a mobile application using PhoneGap with REST API for the backend. The REST API won't be utilised by third-party developers, but will be application-specific, so there is no need for oAuth to be implemented. Hence, I am planning to use Basic Authentication where in the User enters their Username/password to access the API resources. All API communication will be on SSL. Basic Authentication with Token Instead of letting the application store the username/password and

OpenID Connect 验证

一曲冷凌霜 提交于 2020-03-28 18:05:46
OpenID Connect Authentication 几乎所有的 Web 应用程序都提示用户创建账号并登录。为了创建账号,用户被要求提供他们的名字、电子邮件、口令、以及确认口令。不仅这些需要耗费用户很大的负担(50次以上的击键),这还带来安全顾虑,由于用户经常在不同的站点使用相同的口令,而且许多站点并不能有效保护这些凭证。 OpendID 开启了联合标识,这样用户可以使用同样的标识在众多 Web 应用程序之间进行验证,用户和 Web 应用程序都信任标识的提供方,例如 Google、Yahoo 和 Facebook,它们保存用户的配置信息并受应用程序的委托验证用户。这消除了每个 Web 应用程序创建自己的自定义的验证系统的需要,对用户来说,注册和登录遍及互联网的站点也变得更为简易和便捷。 OpenID Connect 是下一代的 OpenID,开发 OpenID Connect 考虑到两个关键因素: 向站点传递访问身份验证信息(用户标识)的权限,非常类似与通过委托访问用户的数据(例如用户的日程)。开发人员不应该为这两种不同的用例使用完全不同的协议。特别是许多开发者需要在应用程序中处理这两者。 规范应该模块化,在不需要实现自动发现、关联和其他复杂情况的情况,保持规范与上一个版本的 OpenID 的延续性。 基本的 OpenID Connect 流为: 通过将用户重定向到标识提供者

如何通过 OIDC 协议实现单点登录?

自古美人都是妖i 提交于 2020-03-27 11:00:55
3 月,跳不动了?>>> 什么是单点登录 我们通过一个例子来说明,假设有一所大学,内部有两个系统,一个是邮箱系统,一个是课表查询系统。现在想实现这样的效果:在邮箱系统中登录一遍,然后此时进入课表系统的网站,无需再次登录,课表网站系统直接跳转到个人课表页面,反之亦然。比较专业的定义如下: 单点登录 (Single Sign On),简称为 SSO ,是目前比较流行的企业业务整合的解决方案之一。 SSO 的定义是在多个应用系统中, 用户只需要登录一次 就可以 访问所有 相互信任的应用系统。 为什么要实现单点登录 单点登录的意义在于能够在不同的系统中统一账号、统一登录。用户不必在每个系统中都进行注册、登录,只需要使用一个统一的账号,登录一次,就可以访问所有系统。 通过 OIDC 协议实现单点登录 创建自己的用户目录 用户目录 这个词很贴切,你的系统的总用户表就像一本书一样,书的封皮上写着“所有用户”四个字。打开第一页,就是目录,里面列满了用户的名字,翻到对应的页码就能看到这个人的邮箱,手机号,生日信息等等。无论你开发多少个应用,要确保你有一份这些应用所有用户信息的 truth source。所有的注册、认证、注销都要到你的用户目录中进行增加、查询、删除操作。你要做的就是 创建一个中央数据表,专门用于存储用户信息 ,不论这个用户是来自 A 应用、B 应用还是 C 应用。 什么是 OIDC

springboot oauth2 token续签

我是研究僧i 提交于 2020-03-26 11:42:29
3 月,跳不动了?>>> 项目中使用了spring oauth2作为接口的权限认证,由于是集群环境,使用了redis存储token信息。一开始使用并没有注意,再后来app在使用的过程中,用户一直操作着,会突然中断跳到登录页,这种体验是很不友好的。问了下客户端的小伙伴,在token过期时,并没有调用刷新token的接口。好吧~那就接口来处理吧。 首先确定的时token的存储和读取都没有问题,就是每次请求后,token 的过期时间没有更新,才会导致token过期操作中断。所以我们要做的就是在每次正常请求接口后,更新token的过期时间。 看了下RedisTokenStore的源码 再看下readAuthentication(OAuth2AccessToken token)方法,只是读取了token之后就返回了,并没有更新的操作 因此,在readAuthentication(OAuth2AccessToken token)方法上改造,其他方法原样照抄RedisTokenStore就行 改造后的结果如下 这样就算改造完成了。 然后在自己的 AuthorizationServer 中注入自己改造的redistokenStore,类似这种 然后再配置token的存储方式的时候,使用自己改造的redisTokenStore,如下 这样redis token续签的功能就实现了。 来源:

聊聊 OAuth 2.0 的 Token 续期处理

佐手、 提交于 2020-03-23 14:56:50
3 月,跳不动了?>>> Token 校验逻辑 // CheckTokenEndpoint.checkToken @RequestMapping(value = "/oauth/check_token") @ResponseBody public Map<String, ?> checkToken(@RequestParam("token") String value) { // 根据 token 查询保存在 tokenStore 的令牌全部信息 OAuth2AccessToken token = resourceServerTokenServices.readAccessToken(value); if (token == null) { throw new InvalidTokenException("Token was not recognised"); } if (token.isExpired()) { throw new InvalidTokenException("Token has expired"); } // 根据 token 查询保存的 认证信息 还有权限角色等 (业务信息) OAuth2Authentication authentication = resourceServerTokenServices.loadAuthentication(token

Accessing network responses in Cypress.io

早过忘川 提交于 2020-03-23 12:21:09
问题 I'm working on testing an OpenID Connect service, using Code and Implicit Flow. I would really like to be able to access the messages I get back from the service, especially the 303 See Other message which has the ID Token. If someone can advise on how to get to response messages I would really appreciate it. Since the services exposes a HTML login page what happens is a cy.get("#loginButton").click() so I don't send a cy.request() and that is because I want to test login using the front-end.

Switch provider for the omniauth-shopify-oauth2 gem in runtime?

痴心易碎 提交于 2020-03-23 08:12:18
问题 The initializer for the omniauth-shopify-oauth2 gem is supposed to look like this: # config/initializers/omniauth.rb Rails.application.config.middleware.use OmniAuth::Builder do provider :shopify, ENV['SHOPIFY_API_KEY'], ENV['SHOPIFY_SHARED_SECRET'] end However, in our Rails app resides a few different brands who offers the same functionality. Throughout the entire app, the request.domain of a request determines which brand you are exposed to ( brand1.example.com , brand2.example.com , etc.).

Springsecurity-oauth2之OAuth2AuthenticationProcessingFilter

我们两清 提交于 2020-03-21 22:27:17
3 月,跳不动了?>>> Spring-security-oauth2的版本是2.0 如下图1所示,继承了Filter,还继承了InitializingBean,这个与SpringIOC有关,在创建Bean的时候,会调用afterPropertiesSet方法,进行一些判断或者初始化之类的操作        图1 我们重点来看下doFilter方法,如下List-1 List-1 OAuth2AuthenticationProcessingFilter的doFilter方法 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { final boolean debug = logger.isDebugEnabled(); final HttpServletRequest request = (HttpServletRequest) req; final HttpServletResponse response = (HttpServletResponse) res; try { Authentication authentication = tokenExtractor.extract(request

【Spring Security + OAuth2 + JWT入门到实战】24. 自定义令牌配置

夙愿已清 提交于 2020-03-21 11:56:46
3 月,跳不动了?>>> 简介 之前获取到的令牌都是基于Spring Security OAuth2默认配置生成的,Spring Security允许我们自定义令牌配置,比如不同的client_id对应不同的令牌,令牌的有效时间,令牌的存储策略等; 自定义令牌配置 让认证服务器 HkAuthorizationServerConfig 继承 AuthorizationServerConfigurerAdapter ,并重写它的 configure(ClientDetailsServiceConfigurer clients) 方法: package com.spring.security; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework