Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support granular token #443

Merged
merged 10 commits into from
Apr 20, 2023
Merged

feat: support granular token #443

merged 10 commits into from
Apr 20, 2023

Conversation

elrrrrrrr
Copy link
Member

@elrrrrrrr elrrrrrrr commented Apr 17, 2023

🚀 Added implementation related to granularToken, mainly used for web authorization scenarios.

  • 📝 Added 1.14.0.sql to add fields and token_packages for granularToken.
  • 🛣️ Added gat related routes, including create, query, and delete api.
  • 🌟 Added tokenService to check granularToken access.
  • 🔄 Modified Token to perform options and data attribute conversions internally in the model.

🚀 新增 granularToken 相关实现,主要用于 web 端授权场景

  • 📝 新增 1.14.0.sql 添加 granularToken 相关字段及 token_packages 中间表
  • 🛣️ 新增 gat 相关路由,包括创建查询删除接口
  • 🌟 新增 tokenService ,处理 granularToken 鉴权
  • 🔄 修改 Token ,在 model 内部进行 options 和 data 属性转换

@elrrrrrrr elrrrrrrr added the enhancement New feature or request label Apr 17, 2023
@elrrrrrrr elrrrrrrr requested review from fengmk2, gemwuu and killagu April 17, 2023 15:16
rules/singleton.js Outdated Show resolved Hide resolved
sql/1.14.0.sql Outdated Show resolved Hide resolved
@fengmk2
Copy link
Member

fengmk2 commented Apr 18, 2023

神奇,chatgpt 的 cr 机器人好像只针对 @elrrrrrrr 能够跑起来。

sql/1.14.0.sql Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Merging #443 (1544d0e) into master (a64c90b) will increase coverage by 0.07%.
The diff coverage is 98.86%.

@@            Coverage Diff             @@
##           master     #443      +/-   ##
==========================================
+ Coverage   97.16%   97.23%   +0.07%     
==========================================
  Files         157      159       +2     
  Lines       14123    14445     +322     
  Branches     1810     1861      +51     
==========================================
+ Hits        13722    14046     +324     
+ Misses        401      399       -2     
Impacted Files Coverage Δ
app/repository/UserRepository.ts 92.90% <92.30%> (+1.08%) ⬆️
app/core/service/TokenService.ts 98.57% <98.57%> (ø)
app/core/entity/Token.ts 100.00% <100.00%> (ø)
app/core/service/UserService.ts 95.93% <100.00%> (+0.80%) ⬆️
app/port/UserRoleManager.ts 100.00% <100.00%> (ø)
app/port/controller/TokenController.ts 99.14% <100.00%> (+0.89%) ⬆️
app/repository/model/Token.ts 100.00% <100.00%> (ø)
app/repository/model/TokenPackage.ts 100.00% <100.00%> (ø)

... and 11 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@elrrrrrrr elrrrrrrr changed the title Granular token WIP: Granular token Apr 18, 2023
sql/1.14.0.sql Outdated Show resolved Hide resolved
@elrrrrrrr
Copy link
Member Author

@fengmk2
尝试通过单独的中间表 token_packages 进行 granularToken 和包关联。
和之前实现有所差别,目前先忽略了无效的 packageName。
参照 Maintainers 实现,通过事务确保删除、新建时数据一致性。

@killagu
根据建议,已调整相关数据结构,新增了 tokenService 提供统一的关联关系查询、权限校验逻辑。

sql review 的规则似乎过于严格 😭,先参照之前的数据表新增了 token_packages

@elrrrrrrr elrrrrrrr requested a review from killagu April 18, 2023 12:02
@elrrrrrrr elrrrrrrr changed the title WIP: feat: support granular token feat: support granular token Apr 18, 2023
@elrrrrrrr elrrrrrrr requested a review from fengmk2 April 19, 2023 02:25
Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@fengmk2 fengmk2 merged commit 92ddf2c into master Apr 20, 2023
@fengmk2 fengmk2 deleted the granular-token branch April 20, 2023 07:27
fengmk2 pushed a commit that referenced this pull request Apr 20, 2023
[skip ci]

## [3.14.0](v3.13.2...v3.14.0) (2023-04-20)

### Features

* support granular token ([#443](#443)) ([92ddf2c](92ddf2c))
@github-actions
Copy link

🎉 This PR is included in version 3.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

hezhengxu2018 pushed a commit to hezhengxu2018/cnpmcore that referenced this pull request Apr 21, 2023
> 🚀 Added implementation related to
[granularToken](https://docs.npmjs.com/about-access-tokens#about-granular-access-tokens),
mainly used for web authorization scenarios.

* 📝 Added `1.14.0.sql` to add fields and `token_packages` for
granularToken.
* 🛣️ Added gat related routes, including `create`, `query`, and `delete`
api.
* 🌟 Added `tokenService` to check granularToken access.
* 🔄 Modified Token to perform options and data attribute conversions
internally in the model.
-----------

> 🚀 新增
[granularToken](https://docs.npmjs.com/about-access-tokens#about-granular-access-tokens)
相关实现,主要用于 web 端授权场景
* 📝 新增 `1.14.0.sql` 添加 granularToken 相关字段及 `token_packages` 中间表
* 🛣️ 新增 gat 相关路由,包括`创建`、`查询`、`删除`接口
* 🌟 新增 `tokenService` ,处理 granularToken 鉴权
* 🔄 修改 Token ,在 model 内部进行 options 和 data 属性转换
hezhengxu2018 pushed a commit to hezhengxu2018/cnpmcore that referenced this pull request Apr 21, 2023
[skip ci]

## [3.14.0](cnpm/cnpmcore@v3.13.2...v3.14.0) (2023-04-20)

### Features

* support granular token ([cnpm#443](cnpm#443)) ([92ddf2c](cnpm@92ddf2c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants