Index.razor
Код: Выделить всё
@page "/"
You see this because you have the sample_role
Everyone sees this
Код: Выделить всё
public class CustomAuth : ServerAutheticationProvider
{
public override async Task GetAuthenticationStateAsync()
{
var state = await base.GetAuthenticationStateAsync();
var currentUserId = state.User.Identity.Name;
// now I fetch permissions for this user from a database
bool userHasRole = Database.DoesRoleExistFor(currentUserId);
if(userHasRole) {
var sample_role = new Claim(ClaimTypes.Role, "sample_role");
var identity = new ClaimsIdentity(new Claim[] { sample_role });
state.User.AddIdentity(identity);
NotifyAuthenticationStateChanged(Task.From(new AutheticationState(state.User)));
}
return state;
}
}
Код: Выделить всё
services.AddScoped();
Этот код также работает на моем личном компьютере, который не является частью какого-либо домена. Значение currentUserId в этом случае — COMPUTERNAME\USERNAME.
Однако, когда я перемещаю свой код в производственную среду с другим именем домена, я получить исключение:
Win32Exception: не удалось установить доверительные отношения между основным доменом и доверенным доменом.
Когда я меняю строку:
Код: Выделить всё
Код: Выделить всё
Как мне решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/732 ... lationship
Мобильная версия