实现生成apiKey接口,便于第三方应用直接在token里携带过来进行认证 #718
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
参考了别的项目apiKey生成和鉴权机制,结合本项目的Oauth2的鉴权机制,在不多新增表的情况下,复用Oauth2的生成token机制,将apiKey的key过期时间设置50年后,并且不需要refreshToken的刷新机制。
![image](https://private-user-images.githubusercontent.com/5793642/392865119-f1567ce3-f025-4297-b9ff-aa44e8e2210f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MzU2MjQsIm5iZiI6MTczODkzNTMyNCwicGF0aCI6Ii81NzkzNjQyLzM5Mjg2NTExOS1mMTU2N2NlMy1mMDI1LTQyOTctYjlmZi1hYTQ0ZThlMjIxMGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMTMzNTI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzRjZGQ0MTZlNzRkYWZmOTE1ZDJiODE0NzU0Yjk5YzFmMjYwZGIzZGE3MGI1ZGNlYWEwMzllMzVmNTMxMGYxNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.3y-kNaEwoQHD39QPjvfb8hBgtNUH0JcATxkqdJaF134)
目前还有点待完善的是当前clientId在代码里设置成apiKey,用户如果在创建第三方应用时如果也写apiKey为客户端编码的话,可能会有一些冲突。
当前简单实现后的效果如下: