Merge remote-tracking branch 'origin/master' into actions-feature-branch

fix merge conflict
This commit is contained in:
Molly Moen 2018-11-14 15:32:41 -08:00
Родитель 295fa965e6 a3ee35f52b
Коммит 7370fb8971
22 изменённых файлов: 50 добавлений и 5 удалений

Просмотреть файл

@ -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");