我使用以下ServiceStack代码创建了我的Auth服务器:
Plugins.Add(new AuthFeature(() => new CustomUserSession(),
new IAuthProvider[] {
new JwtAuthProvider
{
HashAlgorithm = AuthSettings.HashAlgorithm,
RequireSecureConnection = requireSecureConnection,
AuthKeyBase64 = AuthSettings.JwtAuthKeyBase64,
ExpireTokensIn = TimeSpan.FromHours(_configuration["AuthSettings:ExpireTokensIn"].ToDouble()),
ExpireRefreshTokensIn = TimeSpan.FromHours(_configuration["AuthSettings:ExpireRefreshTokensIn"].ToDouble()),
CreatePayloadFilter = (payload,session) => {
payload["zipCode"] = ((CustomUserSession)session).ZipCode;
},
PopulateSessionFilter = AuthSettings.PopulateSessionFilterImplementation
},
new CustomCredentialsAuthProvider((ITsoContext)_serviceProvider.GetService(typeof(ITsoContext))) //HTML Form post of User/Pass
}));
非常简单,然后我从我的http://runningauthservice/types渲染了我的Typescript“dtos.ts”。
我正在使用servicestack-client版本0.0.40
这是我第一次在任何dtos.ts中看到IPost,我是从我的ServiceStack api渲染的,这里是我的auth dto.ts的片段:
// @Route("/assignroles")
// @DataContract
export class AssignRoles implements IReturn<AssignRolesResponse>, IPost
{
// @DataMember(Order=1)
userName: string;
// @DataMember(Order=2)
permissions: string[];
// @DataMember(Order=3)
roles: string[];
createResponse() { return new AssignRolesResponse(); }
getTypeName() { return "AssignRoles"; }
}
Visual Code中的Typescript错误片段: