Copied to clipboard

Flag this post as spam?

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


  • Alfred 1 post 72 karma points
    Nov 06, 2019 @ 13:01
    Alfred
    1

    Unseal MemberAuthorizeAttribute

    Hi Guys,

    I have connected Umbraco 8.2 with Azure B2C so that members can login with their Azure B2C Account. We used the the UmbracoIdentity NuGet package for that (https://github.com/Shazwazza/UmbracoIdentity).

    I needed to create my own AuthorizeAttribute to do a proper redirect to Azure B2C when someone is not logged in and is accessing a route which is requiring authentication.

    I wanted my custom AuthorizeAttribute to inherit from MemberAuthorizeAttribute but this is not possible because that class is sealed:

    https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Web/Mvc/MemberAuthorizeAttribute.cs

    I was wondering why this class is sealed? Would it be a good idea to remove the sealed modifier and let people inherit from it? Now i basically copied and pasted the whole MemberAuthorizeAttribute.cs code into my custom AuthorizeAttribute and made the change i wanted in the "HandleUnauthorizedRequest" method.

    Would love to hear your thoughts. If more people would agree i will be happy to create a PR.

    Kind Regards,

    Alfred

Please Sign in or register to post replies

Write your reply to:

Draft