fix deprecation warnings
This commit is contained in:
parent
5c60b6ace7
commit
a846f041cd
@ -1,33 +1,37 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters
|
||||||
{
|
{
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using Swashbuckle.AspNetCore.Swagger;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Basket.API.Infrastructure.Filters
|
namespace Basket.API.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
|
||||||
|
|
||||||
if (hasAuthorize)
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
{
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
|
if (hasAuthorize)
|
||||||
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
|
{
|
||||||
{
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
{ "oauth2", new [] { "Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator" } }
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
});
|
|
||||||
}
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
}
|
{
|
||||||
}
|
new Dictionary<string, IEnumerable<string>>
|
||||||
}
|
{
|
||||||
|
{ "oauth2", new [] { "Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,37 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters
|
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters
|
||||||
{
|
{
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using Swashbuckle.AspNetCore.Swagger;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Basket.API.Infrastructure.Filters
|
namespace Basket.API.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
|
||||||
|
|
||||||
if (hasAuthorize)
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
{
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
|
if (hasAuthorize)
|
||||||
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
|
{
|
||||||
{
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
{ "oauth2", new [] { "Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator" } }
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
});
|
|
||||||
}
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
}
|
{
|
||||||
}
|
new Dictionary<string, IEnumerable<string>>
|
||||||
}
|
{
|
||||||
|
{ "oauth2", new [] { "Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,10 @@ namespace Basket.API.Infrastructure.Filters
|
|||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
|
|
||||||
if (hasAuthorize)
|
if (hasAuthorize)
|
||||||
{
|
{
|
||||||
|
@ -7,25 +7,28 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters
|
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
internal class AuthorizeCheckOperationFilter : IOperationFilter
|
internal class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
|
|
||||||
if (hasAuthorize)
|
if (hasAuthorize)
|
||||||
{
|
{
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
|
{
|
||||||
{
|
new Dictionary<string, IEnumerable<string>>
|
||||||
{ "oauth2", new [] { "locationsapi" } }
|
{
|
||||||
});
|
{ "oauth2", new [] { "locationsapi" } }
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,27 +6,28 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters
|
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
|
|
||||||
if (hasAuthorize)
|
if (hasAuthorize)
|
||||||
{
|
{
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
{
|
{
|
||||||
new Dictionary<string, IEnumerable<string>>
|
new Dictionary<string, IEnumerable<string>>
|
||||||
{
|
{
|
||||||
{ "oauth2", new [] { "marketingapi" } }
|
{ "oauth2", new [] { "marketingapi" } }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,32 +1,34 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using Swashbuckle.AspNetCore.Swagger;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Infrastructure.Filters
|
namespace Ordering.API.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
|
||||||
|
|
||||||
if (hasAuthorize)
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
{
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
|
if (hasAuthorize)
|
||||||
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
|
{
|
||||||
{
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
{ "oauth2", new [] { "orderingapi" } }
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
});
|
|
||||||
}
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
}
|
{
|
||||||
}
|
new Dictionary<string, IEnumerable<string>>
|
||||||
|
{
|
||||||
|
{ "oauth2", new [] { "orderingapi" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +1,34 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using Swashbuckle.AspNetCore.Swagger;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Webhooks.API.Infrastructure
|
namespace Webhooks.API.Infrastructure
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
|
|
||||||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
|
|
||||||
|
|
||||||
if (hasAuthorize)
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||||
{
|
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||||
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
.OfType<AuthorizeAttribute>().Any();
|
||||||
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
|
if (hasAuthorize)
|
||||||
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
|
{
|
||||||
{
|
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
|
||||||
{ "oauth2", new [] { "webhooksapi" } }
|
operation.Responses.Add("403", new Response { Description = "Forbidden" });
|
||||||
});
|
|
||||||
}
|
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
||||||
}
|
{
|
||||||
}
|
new Dictionary<string, IEnumerable<string>>
|
||||||
|
{
|
||||||
|
{ "oauth2", new [] { "webhooksapi" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user