更新时间:2023-02-15 13:35:25
我发现了AddBasicAutentication方法实际上有一个重载,接受委托提供的角色。这正是我一直在寻找。所以,现在的呼叫AddBasicAuthentication看起来像这样,一切就像一个魅力:
I found out that the AddBasicAutentication method actually has an overload that takes a delegate for providing the roles. This is exactly what I was looking for. So now the call to AddBasicAuthentication looks like this, and everything works like a charm:
authenticationConfiguration.AddBasicAuthentication((userName, password) => accountService.Authenticate(userName, password), (username) => accountService.GetRoles(username));