public AuthorizationOptions WithMechanism(string value) { var tmp = value.ToUpper(); if (!ValidMechanism(tmp)) { throw new LeafConfigurationException($"{value} is not a supported authorization mechanism"); } switch (tmp) { case Saml2: Mechanism = AuthorizationMechanism.Saml2; break; case ActiveDirectory: Mechanism = AuthorizationMechanism.ActiveDirectory; break; default: Mechanism = AuthorizationMechanism.Unsecured; break; } return(this); }
/// <summary> /// Подтвердить права пользователя на чтение данных /// (включает процедуру аутентификации и авторизации). /// </summary> /// <param name="exceptionMessage">Сообщение в случае отсутствия прав.</param> protected void AuthorizeUserToReadData( string exceptionMessage) { if (!AuthorizationMechanism.CanUserReadData(this.CurrentUserInfo)) { this.ThrowUnauthorizedResponseException(exceptionMessage); } }
/// <summary> /// Подтвердить права на совершение любых действий /// (включает процедуру аутентификации и авторизации). /// </summary> /// <param name="exceptionMessage">Сообщение в случае отсутствия прав.</param> protected void AuthorizeGlobalAdmin( string exceptionMessage) { if (!AuthorizationMechanism.IsUserGlobalAdmin(this.CurrentUserInfo)) { this.ThrowUnauthorizedResponseException(exceptionMessage); } }