Merge branch 'adm_master' of https://github.com/Azure/remote-monitoring-services-dotnet into adm_master
This commit is contained in:
Коммит
65f06a3765
|
@ -60,9 +60,6 @@ namespace Services.Test
|
|||
Assert.Equal(claims.FirstOrDefault(k => k.Type == NAME_KEY).Value, result.Name);
|
||||
Assert.Equal(claims.FirstOrDefault(k => k.Type == ID_KEY).Value, result.Id);
|
||||
Assert.NotEmpty(result.AllowedActions);
|
||||
Assert.NotEmpty(result.Roles);
|
||||
Assert.Contains(ADMIN_ROLE_KEY, result.Roles);
|
||||
Assert.Contains(READONLY_ROLE_KEY, result.Roles);
|
||||
foreach (var action in adminPolicy.AllowedActions)
|
||||
{
|
||||
Assert.Contains(action, result.AllowedActions);
|
||||
|
|
|
@ -10,6 +10,5 @@ namespace Microsoft.Azure.IoTSolutions.Auth.Services.Models
|
|||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public List<string> AllowedActions { get; set; }
|
||||
public List<string> Roles { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Microsoft.Azure.IoTSolutions.Auth.Services
|
|||
public interface IUsers
|
||||
{
|
||||
User GetUserInfo(IEnumerable<Claim> claims);
|
||||
List<string> GetAllowedActions(IEnumerable<string> roles);
|
||||
IEnumerable<string> GetAllowedActions(IEnumerable<string> roles);
|
||||
Task<AccessToken> GetToken(string audience);
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,11 @@ namespace Microsoft.Azure.IoTSolutions.Auth.Services
|
|||
Id = id,
|
||||
Name = name,
|
||||
Email = email,
|
||||
AllowedActions = allowedActions,
|
||||
Roles = roles
|
||||
AllowedActions = allowedActions.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public List<string> GetAllowedActions(IEnumerable<string> roles)
|
||||
public IEnumerable<string> GetAllowedActions(IEnumerable<string> roles)
|
||||
{
|
||||
// ensure only unique values are added to the allowed actions list
|
||||
// if duplicate actions are allowed in multiple roles
|
||||
|
|
|
@ -21,14 +21,13 @@
|
|||
"CreateDeployments",
|
||||
"DeleteDeployments",
|
||||
"CreatePackages",
|
||||
"DeletePackages",
|
||||
"ReadAll"
|
||||
"DeletePackages"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": "e5bbd0f5-128e-4362-9dd1-8f253c6082d7",
|
||||
"Role": "readOnly",
|
||||
"AllowedActions": ["ReadAll"]
|
||||
"AllowedActions": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -20,16 +20,12 @@ namespace Microsoft.Azure.IoTSolutions.Auth.WebService.v1.Models
|
|||
[JsonProperty(PropertyName = "AllowedActions", Order = 40)]
|
||||
public List<string> AllowedActions { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "Roles", Order = 50)]
|
||||
public List<string> Roles { get; set; }
|
||||
|
||||
public UserApiModel(User user)
|
||||
{
|
||||
this.Id = user.Id;
|
||||
this.Email = user.Email;
|
||||
this.Name = user.Name;
|
||||
this.AllowedActions = user.AllowedActions;
|
||||
this.Roles = user.Roles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,12 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceGroupListApiModel> GetAllAsync()
|
||||
{
|
||||
return new DeviceGroupListApiModel(await this.storage.GetAllDeviceGroupsAsync());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceGroupApiModel> GetAsync(string id)
|
||||
{
|
||||
return new DeviceGroupApiModel(await this.storage.GetDeviceGroupAsync(id));
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<PackageListApiModel> GetAllAsync()
|
||||
{
|
||||
return new PackageListApiModel(await this.storage.GetPackagesAsync());
|
||||
|
@ -42,7 +41,6 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<PackageApiModel> GetAsync(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task PostAsync()
|
||||
{
|
||||
await this.seed.TrySeedAsync();
|
||||
|
|
|
@ -28,21 +28,18 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("solution-settings/theme")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<object> GetThemeAsync()
|
||||
{
|
||||
return await this.storage.GetThemeAsync();
|
||||
}
|
||||
|
||||
[HttpPut("solution-settings/theme")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<object> SetThemeAsync([FromBody] object theme)
|
||||
{
|
||||
return await this.storage.SetThemeAsync(theme);
|
||||
}
|
||||
|
||||
[HttpGet("solution-settings/logo")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task GetLogoAsync()
|
||||
{
|
||||
var model = await this.storage.GetLogoAsync();
|
||||
|
@ -50,7 +47,6 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPut("solution-settings/logo")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task SetLogoAsync()
|
||||
{
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
this.log = logger;
|
||||
}
|
||||
|
||||
[Authorize("ReadAll")]
|
||||
public StatusApiModel Get()
|
||||
{
|
||||
// TODO: calculate the actual service status
|
||||
|
|
|
@ -18,14 +18,12 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("user-settings/{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<object> GetUserSettingAsync(string id)
|
||||
{
|
||||
return await this.storage.GetUserSetting(id);
|
||||
}
|
||||
|
||||
[HttpPut("user-settings/{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<object> SetUserSettingAsync(string id, [FromBody] object setting)
|
||||
{
|
||||
return await this.storage.SetUserSetting(id, setting);
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<AlarmByRuleListApiModel> GetAsync(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -53,7 +52,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<AlarmByRuleListApiModel> PostAsync([FromBody] QueryApiModel body)
|
||||
{
|
||||
string[] deviceIds = body.Devices == null
|
||||
|
@ -70,7 +68,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListByRuleApiModel Get(
|
||||
[FromRoute] string id,
|
||||
[FromQuery] string from,
|
||||
|
@ -90,7 +87,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListByRuleApiModel Post(
|
||||
[FromRoute] string id,
|
||||
[FromBody] QueryApiModel body)
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet(Version.PATH + "/[controller]")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListApiModel List(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -53,7 +52,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost(Version.PATH + "/[controller]")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListApiModel Post([FromBody] QueryApiModel body)
|
||||
{
|
||||
string[] deviceIds = body.Devices == null
|
||||
|
@ -70,7 +68,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet(Version.PATH + "/[controller]/{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmApiModel Get([FromRoute] string id)
|
||||
{
|
||||
Alarm alarm = this.alarmService.Get(id);
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<MessageListApiModel> GetAsync(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -49,7 +48,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<MessageListApiModel> PostAsync([FromBody] QueryApiModel body)
|
||||
{
|
||||
string[] deviceIds = body.Devices == null
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<RuleApiModel> GetAsync([FromRoute] string id)
|
||||
{
|
||||
Rule rule = await this.ruleService.GetAsync(id);
|
||||
|
@ -29,7 +28,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<RuleListApiModel> ListAsync(
|
||||
[FromQuery] string order,
|
||||
[FromQuery] int? skip,
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<StatusApiModel> Get()
|
||||
{
|
||||
var statusIsOk = true;
|
||||
|
|
|
@ -57,7 +57,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeploymentListApiModel> GetAsync()
|
||||
{
|
||||
return new DeploymentListApiModel(await this.deployments.ListAsync());
|
||||
|
|
|
@ -19,7 +19,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DevicePropertiesApiModel> GetAsync()
|
||||
{
|
||||
return new DevicePropertiesApiModel(await this.deviceProperties.GetListAsync());
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <summary>Get a list of devices</summary>
|
||||
/// <returns>List of devices</returns>
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceListApiModel> GetDevicesAsync([FromQuery] string query)
|
||||
{
|
||||
string continuationToken = string.Empty;
|
||||
|
@ -41,7 +40,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost("query")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceListApiModel> QueryDevicesAsync([FromBody] string query)
|
||||
{
|
||||
string continuationToken = string.Empty;
|
||||
|
@ -57,7 +55,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="id">Device Id</param>
|
||||
/// <returns>Device information</returns>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceRegistryApiModel> GetDeviceAsync(string id)
|
||||
{
|
||||
return new DeviceRegistryApiModel(await this.devices.GetAsync(id));
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="to">Optional. The end time of interesting period</param>
|
||||
/// <returns>The list of jobs</returns>
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<IEnumerable<JobApiModel>> GetAsync(
|
||||
[FromQuery] JobType? jobType,
|
||||
[FromQuery] JobStatus? jobStatus,
|
||||
|
@ -52,7 +51,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="deviceJobStatus">The interesting device job status. `null` means no restrict</param>
|
||||
/// <returns>The job object</returns>
|
||||
[HttpGet("{jobId}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<JobApiModel> GetJobAsync(
|
||||
string jobId,
|
||||
[FromQuery]bool? includeDeviceDetails,
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="query">Where clause of IoTHub query</param>
|
||||
/// <returns>List of module twins</returns>
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<TwinPropertiesListApiModel> GetModuleTwinsAsync([FromQuery] string query)
|
||||
{
|
||||
string continuationToken = string.Empty;
|
||||
|
@ -42,7 +41,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="query">Where clause of IoTHub query</param>
|
||||
/// <returns>List of module twins</returns>
|
||||
[HttpPost("query")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<TwinPropertiesListApiModel> QueryModuleTwinsAsync([FromBody] string query)
|
||||
{
|
||||
return await this.GetModuleTwinsAsync(query);
|
||||
|
@ -53,7 +51,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <param name="moduleId">Module Id</param>
|
||||
/// <returns>Device information</returns>
|
||||
[HttpGet("{deviceId}/{moduleId}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<TwinPropertiesApiModel> GetModuleTwinAsync(string deviceId, string moduleId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(deviceId))
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
/// <summary>Return the service status</summary>
|
||||
/// <returns>Status object</returns>
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public StatusApiModel Get()
|
||||
{
|
||||
return new StatusApiModel(true, "Alive and well");
|
||||
|
|
Загрузка…
Ссылка в новой задаче