Merge remote-tracking branch 'origin/master' into actions-feature-branch
fix merge conflict
This commit is contained in:
Коммит
7370fb8971
|
@ -60,6 +60,9 @@ 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,5 +10,6 @@ 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);
|
||||
IEnumerable<string> GetAllowedActions(IEnumerable<string> roles);
|
||||
List<string> GetAllowedActions(IEnumerable<string> roles);
|
||||
Task<AccessToken> GetToken(string audience);
|
||||
}
|
||||
|
||||
|
@ -83,11 +83,12 @@ namespace Microsoft.Azure.IoTSolutions.Auth.Services
|
|||
Id = id,
|
||||
Name = name,
|
||||
Email = email,
|
||||
AllowedActions = allowedActions.ToList()
|
||||
AllowedActions = allowedActions,
|
||||
Roles = roles
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllowedActions(IEnumerable<string> roles)
|
||||
public List<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,13 +21,14 @@
|
|||
"CreateDeployments",
|
||||
"DeleteDeployments",
|
||||
"CreatePackages",
|
||||
"DeletePackages"
|
||||
"DeletePackages",
|
||||
"ReadAll"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": "e5bbd0f5-128e-4362-9dd1-8f253c6082d7",
|
||||
"Role": "readOnly",
|
||||
"AllowedActions": []
|
||||
"AllowedActions": ["ReadAll"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -20,12 +20,16 @@ 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,12 +19,14 @@ 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,12 +24,14 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<PackageListApiModel> GetAllAsync()
|
||||
{
|
||||
return new PackageListApiModel(await this.storage.GetPackagesAsync());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<PackageApiModel> GetAsync(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task PostAsync()
|
||||
{
|
||||
await this.seed.TrySeedAsync();
|
||||
|
|
|
@ -28,18 +28,21 @@ 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();
|
||||
|
@ -47,6 +50,7 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPut("solution-settings/logo")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task SetLogoAsync()
|
||||
{
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.WebService.v1.Controllers
|
|||
this.log = logger;
|
||||
}
|
||||
|
||||
[Authorize("ReadAll")]
|
||||
public StatusApiModel Get()
|
||||
{
|
||||
// TODO: calculate the actual service status
|
||||
|
|
|
@ -18,12 +18,14 @@ 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,6 +34,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<AlarmByRuleListApiModel> GetAsync(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -52,6 +53,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<AlarmByRuleListApiModel> PostAsync([FromBody] QueryApiModel body)
|
||||
{
|
||||
string[] deviceIds = body.Devices == null
|
||||
|
@ -68,6 +70,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListByRuleApiModel Get(
|
||||
[FromRoute] string id,
|
||||
[FromQuery] string from,
|
||||
|
@ -87,6 +90,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost("{id}")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListByRuleApiModel Post(
|
||||
[FromRoute] string id,
|
||||
[FromBody] QueryApiModel body)
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet(Version.PATH + "/[controller]")]
|
||||
[Authorize("ReadAll")]
|
||||
public AlarmListApiModel List(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -52,6 +53,7 @@ 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
|
||||
|
@ -68,6 +70,7 @@ 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,6 +30,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<MessageListApiModel> GetAsync(
|
||||
[FromQuery] string from,
|
||||
[FromQuery] string to,
|
||||
|
@ -48,6 +49,7 @@ 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,6 +21,7 @@ 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);
|
||||
|
@ -28,6 +29,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<RuleListApiModel> ListAsync(
|
||||
[FromQuery] string order,
|
||||
[FromQuery] int? skip,
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceTelemetry.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<StatusApiModel> Get()
|
||||
{
|
||||
var statusIsOk = true;
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeploymentListApiModel> GetAsync()
|
||||
{
|
||||
return new DeploymentListApiModel(await this.deployments.ListAsync());
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DevicePropertiesApiModel> GetAsync()
|
||||
{
|
||||
return new DevicePropertiesApiModel(await this.deviceProperties.GetListAsync());
|
||||
|
|
|
@ -28,6 +28,7 @@ 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;
|
||||
|
@ -40,6 +41,7 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.WebService.v1.Controllers
|
|||
}
|
||||
|
||||
[HttpPost("query")]
|
||||
[Authorize("ReadAll")]
|
||||
public async Task<DeviceListApiModel> QueryDevicesAsync([FromBody] string query)
|
||||
{
|
||||
string continuationToken = string.Empty;
|
||||
|
@ -55,6 +57,7 @@ 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,6 +32,7 @@ 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,
|
||||
|
@ -51,6 +52,7 @@ 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,6 +25,7 @@ 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;
|
||||
|
@ -41,6 +42,7 @@ 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);
|
||||
|
@ -51,6 +53,7 @@ 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,6 +23,7 @@ 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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче