DRAG DROP
You are developing an ASP.NET Web API for a home inventory management system.
You need to limit access to users with IP addresses based only in the United States.
You have the following code:
Which code segments should you include in Target 1 and Target 2 to complete the code? (To answer,
drag the appropriate code segments to the correct targets in the answer area. Each code segment may
be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll
to view content.)
Was confusing at first, but I found out that there are at least 2 AuthorizeAttributes: MVC and Web API.
For MVC AuthorizationContext is being used, Web API uses HttpActionContext.
So the answer should be:
Target 1: AuthorizeAttribute
Target 2: HttpActionContext (since we are dealing with Web API)
http://stackoverflow.com/questions/26464848/custom-authorization-in-asp-net-webapi-what-a-mess
https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api
+
AuthorizeAttribute. Extend this class to perform authorization logic based on the current user and the user’s roles. – we don’t care about roles and users, we need to block IP. so –
AuthorizationFilterAttribute. Extend this class to perform synchronous authorization logic that is not necessarily based on the current user or role.
AuthorizationFilterAttribute and HttpActionContext
agree