Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add DynamicTokenProvider. #239

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

Open
vicenteyu wants to merge 13 commits into dotnetcore:master
base: master
Choose a base branch
Loading
from vicenteyu:Branch_DynamicToken

Conversation

@vicenteyu
Copy link

@vicenteyu vicenteyu commented Nov 21, 2023

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

EzrealJ reacted with eyes emoji
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

@vicenteyu vicenteyu Nov 21, 2023

Choose a reason for hiding this comment

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

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

Copy link
Collaborator

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

vicenteyu reacted with thumbs up emoji

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 <^@^>
Signed-off-by: Vicente.Yu <^@^>
Copy link
Author

使用 MultiUserOAuthTokenAttribute 替代

Signed-off-by: Vicente.Yu <^@^>
Copy link
Author

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

Copy link
Collaborator

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

Copy link

fengb3 commented Oct 12, 2024

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

Copy link
Collaborator

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

Copy link

fengb3 commented Oct 12, 2024

@fengb3

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

有相关文档吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@EzrealJ EzrealJ EzrealJ left review comments

@xljiulang xljiulang Awaiting requested review from xljiulang

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /