140 Star 1.2K Fork 339

GVP符节开源 / jap

2021-12-07 11:31
784199 yadong.zhang 1578932767 yadong.zhang

修复部分BUG

最后提交信息为: Merge branch 'dev'
2021-11-02 21:56
784199 yadong.zhang 1578932767 yadong.zhang

最后提交信息为: :memo:change: CHANGELOGS.md
2021-09-24 13:45
784199 yadong.zhang 1578932767 yadong.zhang
  • feat: Add jap-http-api module. (Gitee Issue #I43ZS7:增加 jap-http-api 模块)
  • feat: Add jap-ids-web module. Package the filter of ids as a separate component.
  • feat: add HTTP servlet adapter to decouple jakarta servlets. Note [1]
  • feat: [jap-social] Support to bind the account of the third-party platform. (Gitee
    Issue #I46J6W:jap-social 不方便做已经登陆,绑定第三方登陆的场景)
  • change: [jap-ids] scope changed to optional.
  • change: [jap-sso] Upgrade kisso to 3.7.7, Solve the vulnerability of jackson.
  • change: [jap-mfa] Upgrade googleauth to 1.5.0, Solve the vulnerability of apache httpclient.
  • change: Replace the theme of the document site https://justauth.plus to solve the problem of
    the soaring memory of the document site. (Gitee Issue I4958H | Github
    Issue 8)
  • change: Upgrade simple-http to 1.0.5.
  • change: Upgrade JustAuth to 1.16.4.
  • change: Optimize code.

Note [1]:

In versions prior to version 1.0.5 of jap, rely on the HttpServletRequest, Cookie, HttpServletResponse,
and HttpSession under the javax.servlet.http package in jakarta-servlet, such as:

// Interface provided by jap
public interface JapStrategy {
  default JapResponse authenticate(AuthenticateConfig config, HttpServletRequest request, HttpServletResponse response) {
    return null;
  }
}
// Use jap in spring framework
XxJapStrategy.authenticate(config,request,response);

In order to improve the adaptability of the framework, since version 1.0.5, JAP removed the dependency
of jakarta-servlet and adopted a new set of interfaces (reference: jap-http ).

The developer needs to adapt the original request when calling the JAP interface.

For example, if the developer uses jakarta-servlet, then the HttpServletRequest needs to be adapted:

// Use 1.0.5 or higher version of jap in spring framework
XxJapStrategy.authenticate(config,new JakartaRequestAdapter(request),new JakartaResponseAdapter(response));

注[1]:

在 1.0.5 以前版本,jap 中依赖 jakarta-servletjavax.servlet.http 包下的 HttpServletRequestCookieHttpServletResponse
HttpSession,比如:

// jap 提供的接口
public interface JapStrategy {
  default JapResponse authenticate(AuthenticateConfig config, HttpServletRequest request, HttpServletResponse response) {
    return null;
  }
}
// 在spring框架中使用 jap
XxJapStrategy.authenticate(config,request,response);

为了提高框架适配性,自 1.0.5 版本开始,JAP 去掉了 jakarta-servlet 依赖,采用了一套全新的接口(参考:jap-http),开发者在调用
JAP 接口时需要对原 request 进行适配。

比如,开发者使用了 jakarta-servlet,那么需要对 HttpServletRequest 进行适配处理:

// 在spring框架中使用 1.0.5 或更高级版本的 jap
XxJapStrategy.authenticate(config,new JakartaRequestAdapter(request),new JakartaResponseAdapter(response));

jap-http-api 更多使用帮助,请参考:https://justauth.plus/quickstart/jap-http-api/

最后提交信息为: :memo:Writing docs.
2021-08-15 22:20
784199 yadong.zhang 1578932767 yadong.zhang

最后提交信息为: :bookmark:release 1.0.4
2021-07-28 14:33
784199 yadong.zhang 1578932767 yadong.zhang
最后提交信息为: :bookmark:release 1.0.3
2021-05-24 08:49
784199 yadong.zhang 1578932767 yadong.zhang

新功能/特性

jap-ids 模块

  • IdsConfig中添加 enableDynamicIssuer 属性,boolean 类型。当 enableDynamicIssuer=true 时,开发者不再需要单独设置 issuerjap-ids 将从当前请求的域名中自动提取 issuer

此功能针对客户端支持自定义域名的业务场景。可以通过域名的标识(比如二级域名jap.justauth.plus 中的标识就是 jap)确定用户所属的客户端(也可以对应到租户)。

  • IdsConfig 中添加 loginPageUrl 属性,loginPageUrlloginUrl 的区别:
  • loginPageUrl:登录表单页面 URL,关键字:页面
  • loginUrl:登录的api URL,关键字:API
  • IdsConfig中添加 externalLoginPageUrl 属性,boolean 类型。

如果授权服务未提供登录页面(登录页面由其他服务托管,比如登录页面在单独的静态服务中部署),则需要启用此配置。

  • IdsConfig中添加 externalConfirmPageUrl 属性,boolean 类型。

如果授权服务未提供授权确认页面(授权确认页面由其他服务托管,比如授权确认页面在单独的静态服务中部署),则需要启用此配置。

  • IdsConfig中添加 authorizeAutoApproveUrl 属性。

当授权 URL 中包含 autoapprove=true 时,授权服务器在用户登录完成后,不会跳转到 confirmPageUrl,而是直接跳转到 authorizeAutoApproveUrl

  • 添加 IdsUserStoreService 接口类,以支持登录后对用户数据的自定义操作,默认为 Session 存储用户信息。感谢微信用户(antscqy)的建议
  • 添加 IdsPipeline 接口,开发人员可以自定义流程,目前仅支持自定义 IdsxxFilter(过滤器)和 LoginEndpoint 的流程。
  • 添加 spi 插件机制,jap-ids 对外提供的接口,都可以以 spi 的形式实现。
  • 添加以下内置 scope:profile, address, read and write
  • OauthUtil#createAuthorizeUrl(String, IdsRequestParam) 中添加 uid 参数(可选的参数)。

jap-social 模块

  • SocialStrategy 对外提供 refreshTokenrevokeTokengetUserInfo 方法。感谢群友的反馈。

修改

POM 依赖

  • javax.servlet-api 依赖替换为 jakarta.servlet-api

jap-ids 模块

涉及到字段、方法的修改,请升级的时候注意。

  • IdsConfig.confirmUrl 参数名称修改为 confirmPageUrl
  • ApprovalEndpoint#getAuthClientInfo(HttpServletRequest) 的返回类型修改为IdsResponse<String, Map<String, Object>>
  • Ap provalEndpoint#authorize(HttpServletRequest) 的返回类型修改为 IdsResponse<String, String>
  • AuthorizationEndpoint#agree(HttpServletRequest) 的返回类型修改为 IdsResponse<String, String>
  • LoginEndpoint#signin(HttpServletRequest) 的返回类型修改为 IdsResponse<String, String>
  • LogoutEndpoint#logout(HttpServletRequest) 的返回类型修改为 IdsResponse<String, String>
  • 修改 ClientDetail 类的注释。
  • IdsResponse#getData() 方法的返回类型修改为泛型
  • 删除 IdsScopeProvider#initScopes(List<IdsScope>) 方法,不再允许重置系统内置的 scope,新版 jap-ids 支持添加新的 scope 以及 修改内置的 scope 描述。
  • response_type=id_token时,id_token 中将返回用户的基本信息(依据 scope 授权范围)。
  • 优化 UserInfoEndpoint#getCurrentUserInfo(HttpServletRequest) 方法的业务流程,对于用户的特定属性,比如手机号、邮箱等,按照提供的 scope 决定是否返回。
  • 修改 IdsUserService 接口的loginByUsernameAndPasswordgetByName 方法,分别新增了 clientId 入参。

针对多租户场景下,同一个用户可能存在多个租户主体下,单纯依靠用户账密已经无法唯一确定一个用户,这种情况下业务系统可以根据 clientId 获取具体的租户下的用户信息。

PR

最后提交信息为: :memo:Writing docs.
2021-04-21 12:59
784199 yadong.zhang 1578932767 yadong.zhang

v1.0.1(2021-04-20)

新增

  • 添加 com.fujieid.jap.core.util.RequestUtil
  • 完成jap-ids模块

jap-ids 是基于 RFC6749RFC7636RFC7033等标准协议和 OpenID Connect Core 1.0 认证协议,实现的一款轻量级、业务解耦、开箱即用的新一代国产授权认证框架。

jap-ids 目前已支持以下功能

  • 授权码模式(Authorization Code Grant)
  • 授权码-PKCE模式(Proof Key for Code Exchange)
  • 隐式授权模式(Implicit Grant)
  • 密码授权模式(Resource Owner Password Credentials Grant)
  • 客户端授权模式(Client Credentials Grant)
  • 刷新 access_token
  • 回收 access_token
  • 获取当前授权用户的基本信息
  • 校验登录状态
  • 异常提示
  • 退出登录
  • 服务发现(OpenID Connect Discovery)
  • JWK 端点(JWKS)
  • JWK 令牌颁发
  • 自定义 JWT 加解密证书
  • 支持多种 response type(codetokenid_tokenid_token tokencode id_tokencode tokencode id_token token

修改

  • [jap-oidc] 优化 OidcStrategy#authenticate 方法,缓存 OidcDiscoveryDto,减少不必要的 http 请求
  • [jap-oidc] 优化 OidcUtil 工具类的代码,解决一些已知问题
  • [jap-social] 解决一些已知问题
  • 重构 com.fujieid.jap.core.cache.JapLocalCache,实现定时器,定期清理本地缓存

PR

Issue

最后提交信息为: :white_check_mark:update unit test.
预览版本
2021-03-07 18:02
784199 yadong.zhang 1578932767 yadong.zhang

Modified

  • 修复 JapErrorCode 中的描述错误
  • 改进 JapTokenHelper

PR

最后提交信息为: :memo:Writing docs.
预览版本
2021-03-05 11:04
784199 yadong.zhang 1578932767 yadong.zhang

jap-core

新功能

  • 增加 JapErrorCode 枚举类,限定异常码和提示
  • 增加 JapResponse 类,规范接口返回内容
  • 增加 JapTokenHelper 类,统一管理用户的Token
  • 增加 JapContext 类,维护 JAP 上下文信息
  • 增加 JapAuthentication 类,统一管理登录状态信息以及 JAP 上下文信息

修改

  • 修改包结构
    • AuthenticateConfig,JapConfig 移到 com.fujieid.jap.core.config 包中
    • JapUtil 移到 com.fujieid.jap.core.util 包中
  • 删除文件
    • 删除 JapCacheContextHolder
  • 修改代码
    • 重构 AbstractJapStrategy,引入上下文 JapContextJapAuthentication
    • 重构 JapConfig 类,仅保留 ssossoConfig 属性,同时增加 tokenExpireTimecacheExpireTime 参数
    • 修改 JapCacheConfig 中的缓存默认有效期为7天
    • 修改 JapUserService 接口类中的默认内容
    • JapCache 中添加 void removeKey(String key) 方法
    • JapException 中增加 errorCodeerrorMessage 属性,方便将异常信息处理为统一格式的返回数据
    • JapStrategy 接口中 authenticate 方法的返回类型修改为 JapResponse,所有模块的策略方法都返回统一格式的数据
    • JapUser 中增加 token 属性,登录完成后将自动返回 JAP Token
    • JapUtil 类中为 redirect 方法打上 @Deprecated 标记,未来可能删除。同时增加 createToken 方法

jap-oauth2

  • 修改 Oauth2Strategyauthenticate 方法,统一返回 JapResponse

jap-oidc

  • 修改 OidcStrategyauthenticate 方法,统一返回 JapResponse

jap-simple

  • 修改 SimpleStrategyauthenticate 方法,统一返回 JapResponse

jap-social

  • 修改 SocialStrategyauthenticate 方法,统一返回 JapResponse

jap-sso

  • 修改 JapSsoHelper#login 方法的返回值为当前用户的 JAP Token
  • 新增 JapSsoUtil 类,处理 Token
  • JapSsoConfig 类中,删除 loginUrllogoutUrl 属性

Other

  • 增加一些单元测试
2021-02-18 22:12
784199 yadong.zhang 1578932767 yadong.zhang

增加

  • jap-mfa 模块,实现 TOTP 验证
  • JapUserStoreContextHolder 中增加 logout 方法,一键退出登录,支持清除 Cookie、Session等
  • 添加单元测试

修改

  • 更新 jap.sh 脚本,支持多种常用命令
  • 完善注释
  • 删除 JapConfig 中的 options 属性,同时在 SocialConfig 中增加 justAuthConfig 属性
  • RememberMeDetailsUtils 的名称修改为 RememberMeUtils
  • Oauth2Strategy#checkOauthConfig()Oauth2Strategy#isCallback() 方法移到了 Oauth2Util 类中

其他

  • 改进部分代码
  • 重构 SimpleConfig 类,将非必要配置项和业务逻辑,移到工具类 RememberMeUtils
最后提交信息为: :memo:Writing docs.
预览版本
2021-02-01 15:20
784199 yadong.zhang 1578932767 yadong.zhang

增加

  • 增加缓存模块com.fujieid.jap.core.cache.JapCache
  • jap-oauth2 模块中增加 state 校验的逻辑
  • 添加一些package-info.java

修改

  • 修改注释
  • 解决 PkceUtilCodeVerifier 只能本地缓存的问题,借助 com.fujieid.jap.core.cache.JapCache 可以自定义实现分布式缓存
  • simple-json 升级到 0.0.2

其他

  • 修复 javadoc 编译失败的问题
预览版本
2021-01-28 14:30
784199 yadong.zhang 1578932767 yadong.zhang

JAP 是一款开源的登录中间件,基于模块化设计,并且与业务高度解耦,使用起来非常灵活,开发者可以毫不费力地将 JAP 集成到任何 web 应用程序中,就像集成 JA 一样,简单方便。Just auth into any app!

目前实现的功能

最后提交信息为: :wrench:Changing pom.xml
Java
1
https://gitee.com/fujieid/jap.git
git@gitee.com:fujieid/jap.git
fujieid
jap
jap

搜索帮助