Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ashkan Sirous 38 posts 232 karma points
    Sep 25, 2017 @ 08:46
    Ashkan Sirous
    0

    Some Api's with security and some without it

    I have a simple application. I need to implement some Api's with security (to be used it in back office) and some without it (to be used in the website).

    I've read the Article in the documentation: https://our.umbraco.org/documentation/Implementation/Rest-Api/

    But how can I enable it only for 1 controller and not for the other?

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 09:30
    Alex Skrypnyk
    1

    Hi Ashkan

    Try to use "Umbraco.Web.WebApi.UmbracoAuthorizedApiController", I think it's what you need, read more:

    https://our.umbraco.org/documentation/Implementation/Controllers/

  • Ashkan Sirous 38 posts 232 karma points
    Oct 09, 2017 @ 11:39
    Ashkan Sirous
    100

    Thanks Alex for reply,

    I wasn't working on the issue for some days so sorry if I'm late.

    I have tried UmbracoAuthorizedApiController as you've suggested but it keep giving me "401 Unauthorized" now.

    What could be wrong?

    The only thing that I could think of was Cookies, so I've checked that. There is a Cookie attribute with UMB-XSRF-TOKEN and UMB-XSRF-V, etc in my request headers.

    P.S: I've changed my routing using attributes and it was working fine. I still don't think that the problem is related to that, since it is not returning 404, but in case there is a relation:

        [RoutePrefix("api/admins")]
       public class AdminsController : UmbracoAuthorizedApiController
    
Please Sign in or register to post replies

Write your reply to:

Draft