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

Refresh Token with Union-Type Returning Handler #597

Open
URBA22 opened this issue Feb 5, 2024 · 5 comments
Open

Refresh Token with Union-Type Returning Handler #597

URBA22 opened this issue Feb 5, 2024 · 5 comments
Labels
enhancement New feature or request up for grabs community contribution is needed for this issue

Comments

@URBA22
Copy link

URBA22 commented Feb 5, 2024

Hi,
in my application, I have a login endpoint using Union-Type Returning Handler, so my class is:

sealed class Login : Endpoint<
    LoginRequest,
    Results<Ok<LoginResponse>, UnauthorizedHttpResult>> {

    ...

    public override async Task<Results<Ok<LoginResponse>, UnauthorizedHttpResult>> ExecuteAsync(LoginRequest req, CancellationToken ct)
    {
        ...
    }

    ...

}

I have an issue when I try to use JWT Refresh Token Service to implement my refresh token endpoint and logic: the refresh endpoint response type can't be converted to login endpoint response type, because it's a union of typed result.

Is there a way to do something similar?
For the moment, I have to code both login and refresh endpoint independently, without using the token service.

@dj-nitehawk
Copy link
Member

yeah the built-in refresh token functionality is not compatible with the union type responses. the refresh token feature was built before microsoft came out with the union type. we don't want to introduce a breaking change to that feature at this point in time. will look in to supporting it in the future. so your options right now would be to roll your own refresh token functionality or not use the union type responses.

if the community wants to have a go at it, a PR would be highly welcome 😉

@dj-nitehawk dj-nitehawk added enhancement New feature or request up for grabs community contribution is needed for this issue labels Feb 5, 2024
@URBA22
Copy link
Author

URBA22 commented Feb 5, 2024

Ok, thank you for the quick response!

@URBA22 URBA22 closed this as completed Feb 5, 2024
@dj-nitehawk
Copy link
Member

i'll leave this issue open so that someone can look in to implementing it.
thanks!

@dj-nitehawk dj-nitehawk reopened this Feb 5, 2024
@tcortega
Copy link
Contributor

tcortega commented Apr 2, 2024

i'll leave this issue open so that someone can look in to implementing it. thanks!

Why not simply make internal Task<TResponse> CreateToken(string userId, Action<UserPrivileges>? privileges, object? request); public?

@dj-nitehawk
Copy link
Member

@tcortega i've forgotten the details of how this was implemented, and don't have the capacity to look in to it anytime soon. if you'd like to have a crack at a PR, that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request up for grabs community contribution is needed for this issue
Development

No branches or pull requests

3 participants