Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 471295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:58:18+00:00 2026-05-12T23:58:18+00:00

Where is the most fitting place for security and roles authorization to fit into

  • 0

Where is the most fitting place for security and roles authorization to fit into the model view presenter design pattern?

Would it be for all pages that implement security to implement a specific interface, say IAuthorizedView that’s along the lines of

public interface IAuthorizedView : IView
{
    IUser user;
    void AuthorizationInitialized();
    void AuthorizationInvoked();
}

Then handled inside the presenter level

public abstract class Presenter<TView> where TView : IView
{
    public TView View { get; set; }

    public virtual void OnViewInitialized()
    {
    }

    public virtual void OnViewLoaded()
    {
    }
}

public abstract class AuthorizationSecuredPresenter<TView> 
                        : Presenter<TView> where TView : IAuthorizedView 
{
    public override void OnViewInitialized()
    {
        View.AuthorizationInitialized();
        base.OnViewInitialized();
    }

    public override void OnViewLoaded()
    {
        View.AuthorizationInvoked();
        base.OnViewLoaded();
    }
}

This would be my first idea on it, the only question this would leave me is if we move from solely web based and added any type of API that required authorization on the service level that there would end up alot of duplication of access checking or is that perfectly acceptable to verify twice and should be designed for up front?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:58:18+00:00Added an answer on May 12, 2026 at 11:58 pm

    Here is something that you might want to consider.

    I would use the decorator pattern to authorize each call to your object separatly.

    Let’s say you have the following class:

    public class MyService
    {
        public virtual void DoSomething()
        {
            //do something on the server
        }
    }
    

    You would then proceed to create a base decorator to implement the default constructor like this:

    public class MyServiceDecoratorBase : MyService
    {
        public MyServiceDecoratorBase(MyService service)
        {
        }
    }
    

    Once this is setup, you can actually start to decorate by creating an authorization decorator like this:

    public class MyServiceAuthorizationDecorator : MyServiceDecoratorBase
    {
        private readonly MyService _service;
        public MyServiceDecoratorBase(MyService service)
        {
            _service = service;
        }
    
        public override void DoSomething()
        {
            //TODO: Authorize the user here.
            _service.DoSomething();
        }
    }
    

    So now that the main classes are done… how are you going to call all this? Easy!

    MyService service = new MyServiceAuthorizationDecorator(new MyService());
    service.DoSomething();
    

    Now… the advantage of all that is that your authorization logic is completely decoupled from your main service(or object) logic. Why is this important? Testability. You can test your main service independently of your authorization logic. This correspond to the Open/Close Principle.

    Now, let’s say you want to calculate performance on those pesky methods… add a decorator! Logging? Another decorator! They can all be chained that way. Of course, the more you add and the heavier it gets but I think that it’s worth it for the advantage it gives.

    Comments?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get your input on what would be the most fitting
Most of the MVC samples I have seen pass an instance of the view
I'm looking for a non-linear curve fitting routine (probably most likely to be found
most of the time in the service code I would have something like this:
I would like to find the R implementation that most closely resembles Stata output
Most, if not all, tutorials use CGPDFDocumentCreateWithURL(). What is the difference if using CGPDFDocumentCreateWithProvider()
Most games come with their resources (models, textures, etc.) packed into special files (like
Most events bubble in all browsers. However, I know that in Internet Explorer submit
Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever,
Most of time we represent concepts which can never be less than 0. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.