Skip to content

add DynamicTokenProvider. #239

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

vicenteyu
Copy link

多个应用,共享一套api 的TokenProvider机制。

Vicente Yu added 3 commits December 29, 2022 18:37
Signed-off-by: Vicente Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Copy link
Collaborator

Choose a reason for hiding this comment

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

IgnoreAttribute可以和WDynamicTokenAttribute合并,参考HeaderAttribute

/// </summary>
/// <param name="serviceProvider">服务提供者</param>
/// <returns></returns>
protected abstract Task<TokenResult?> RequestTokenAsync(IServiceProvider serviceProvider);
Copy link
Collaborator

Choose a reason for hiding this comment

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

RequestTokenAsync可能需要携带identifier参数

/// <param name="serviceProvider">服务提供者</param>
/// <param name="refresh_token">刷新token</param>
/// <returns></returns>
protected abstract Task<TokenResult?> RefreshTokenAsync(IServiceProvider serviceProvider, string refresh_token);
Copy link
Collaborator

Choose a reason for hiding this comment

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

RefreshTokenAsync可能需要携带identifier参数?

Copy link
Author

Choose a reason for hiding this comment

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

RefreshTokenAsync 按理不用,是以token换token。

@EzrealJ EzrealJ requested a review from xljiulang November 21, 2023 12:55
@xljiulang
Copy link
Collaborator

这个接口的设计,与原体系偏离了,没有能够利用起ITokenProviderFactory的功能。
要实现一个TokenProvider支持多个以key来区分的token,只需要参考DI的Key模式,为ITokenProvider增加 void ClearToken(sting Key);Task<TokenResult> GetTokenAsync(string key);即可。

@vicenteyu
Copy link
Author

这个接口的设计,与原体系偏离了,没有能够利用起ITokenProviderFactory的功能。 要实现一个TokenProvider支持多个以key来区分的token,只需要参考DI的Key模式,为ITokenProvider增加 void ClearToken(sting Key);Task<TokenResult> GetTokenAsync(string key);即可。

懂了懂了,感谢!

Vicente.Yu added 9 commits November 22, 2023 18:22
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
Signed-off-by: Vicente.Yu <^@^>
@vicenteyu
Copy link
Author

使用 MultiUserOAuthTokenAttribute 替代

@vicenteyu vicenteyu closed this May 31, 2024
@vicenteyu vicenteyu reopened this May 31, 2024
Signed-off-by: Vicente.Yu <^@^>
@vicenteyu
Copy link
Author

WebApplication1 模拟客户端,有10个APP,轮流调用API。
WebApplication2 模拟服务端,提供 访问API 和 获取Token 接口。

@xljiulang
Copy link
Collaborator

使用AliasOAuthTokenAttribute来实现。
此实现不需要改动到ITokenProviderFactory和ITokenProvider两个核心接口,所有TokenProvider实现类依然能使用。

@fengb3
Copy link

fengb3 commented Oct 12, 2024

这个功能 还提供吗? 我现在 有需求就是同一个接口, 根据业务需求用不同的token去调用.

@xljiulang
Copy link
Collaborator

@fengb3
当前支持到注册为多个别名,使用时通过别名参数指定。

@fengb3
Copy link

fengb3 commented Oct 12, 2024

@fengb3

当前支持到注册为多个别名,使用时通过别名参数指定。

有相关文档吗?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants