1
refresh-token
とJwtAuthProviderReader
を使用するのに最適な方法が不思議です。私のjwtが期限切れになった瞬間、私は新しいものを得るために/access-token
を要求します。JwtAuthProviderReaderでトークンをリフレッシュ
var jwt = authClient.Send(new GetAccessToken() {RefreshToken = Request.GetCookieValue("ss-refreshtok") }).AccessToken;
Response.SetCookie(new Cookie()
{
Path = "/",
Name = "ss-tok",
Value = jwt
});
私の問題は、私はすでにクッキーに新しいJWTを設定していてもを「トークンの有効期限が切れた」取得することです。私はここで
は私認証サービスです...それが有効になる前にページにいくつかの時間をリフレッシュする必要があります。public class AuthenticationHandler: Service
{
private readonly JsonServiceClient authClient;
public AuthenticationHandler()
{
authClient = new JsonServiceClient("http://localhost/authentication/");
}
[Authenticate]
public GetAuthenticationContextResponse Get(GetAuthenticationContext request)
{
var authSession = this.SessionAs<MyAbaxAuthSession>();
return new GetAuthenticationContextResponse
{
CustomerId = authSession.CustomerId,
UserId = int.Parse(authSession.UserAuthId)
};
}
public UserAuthenticateResponse Post(UserAuthenticate request)
{
var response = authClient.Send(new Authenticate
{
provider = "credentials",
UserName = request.UserName,
Password = request.Password,
UseTokenCookie = true
});
Response.SetCookie(new Cookie()
{
Path = "/",
Name = "ss-tok",
Value = response.BearerToken
});
Response.SetCookie(new Cookie()
{
Path = "/",
Name = "ss-refreshtok",
Value = response.RefreshToken
});
return new UserAuthenticateResponse();
}
}