Base solution for your next web application

Activities of "tonywr"

Hi there,

I am trying to add simple security to a class that inherits from ApplicationService.

My understanding is that I should be able to add a my own class that inherits from IPermissionChecker, and that if I add an AbpAuthorize attribute to a method, then it should run the IsGrantedAsync method to see if it has the permissions.

So I created the following class

public class MyTestPermissionChecker : IPermissionChecker
    {

        public Task<bool> IsGrantedAsync(long userId, string permissionName)
        {
            return Task.FromResult<bool>(true);
        }

        public Task<bool> IsGrantedAsync(string permissionName)
        {
            return Task.FromResult<bool>(true);
        }
    }

and in the constructor of my class, I switch out the permission checker with my own

public class MyAppService : ApplicationService, IQuoteCaptureAppService
{
    public QuoteCaptureAppService(...lots of injected classes)
    {
...lots of setting of injected classes into module level variables
          this.PermissionChecker = new MyTestPermissionChecker();
    }
}

My test method looks like this:

[AbpAuthorize("Test.Permission")]
public GetMyTestOutput GetMyTest(GetMyTestlInput input)
{
           ..do stuff
}

But when I run the code, it raises an exception Abp.Authorization.AbpAuthorizationException with the message " No user logged in!"

I do not want to load in the whole Abp.Zero module.

What do I need to do to make Abp recognise that I am logged in?

I have now downloaded the Simple Task System and installed the Abp.Zero.Ldap package.

I have implemented the User.cs and Tenant.cs classes in SimpleTaskSystem.Core.

I have added MyLdapAuthenticationSource.cs in SimpleTaskSystem.Core.

I have added

public override void PreInitialize()
{
    Configuration.Modules.ZeroLdap().Enable(typeof(MyLdapAuthenticationSource));
}

in to the SimpleTaskSystemCoreModule

The system compiles successfully.

I then run the SimpleTaskSystem.WebSpaAngular project and it fails to execute angular code.

It displays all the angular tags in the page, such as Task List - {{vm.getTaskCountText()}} and {{vm.currentLanguage.displayName}}

I have put an image of what I am seeing here: [http://1drv.ms/1JLNfQj])

I have put a copy of the SimpleTaskSystem with my Ldap changes here: [https://github.com/tonywr71/SimpleTaskSystemWithLdap])

If anyone can help me, that would be much appreciated.

Ok, still on the topic, which is getting Active Directory working with Abp.

As I've said before, I am currently modifying the AbpCompanyName.AbpProjectName sample application to get it authenticating properly with Ldap.

The application compiles properly, and runs, but it still redirects to the Account Login page.

I have found the code where it redirect to the Account Login page, which is in App_Start\Startup.cs

public void Configuration(IAppBuilder app)
{
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });

            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
}
  1. How do I change this to get it to recognise the logged on Active Directory account?
  2. I have added the following line to system.web, which I think makes sense in IIS. Is this the correct way to go about this?
<system.web>
...
    <authentication mode="Windows"/>
</system.web>
  1. How do I determine who the currently logged in user is?

Thanks again, Tony

Never mind, I found the issue. I had to include another couple of using statements and add a DependsOn statement to the class. It now looks like this, which compiles:

using System.Reflection; using Abp.Modules; using Abp.Zero; using Abp.Zero.Ldap; using Abp.Configuration.Startup; using Abp.Zero.Ldap.Configuration;

namespace AbpCompanyName.AbpProjectName { [DependsOn(typeof(AbpZeroCoreModule))] public class AbpProjectNameCoreModule : AbpModule { public override void PreInitialize() { Configuration.Modules.ZeroLdap().Enable(typeof(MyLdapAuthenticationSource)); }

    public override void Initialize()
    {
        IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
    }
}

}

Hi there,

I am also trying to implement Ldap Authentication.

I have set up the AbpCompanyName project so that I can implement the proof of concept.

As per the instructions, I have installed the Abp.Zero.Ldap package into the AbpCompanyName.AbpProjectName.Core package.

The Abp.Zero.Ldap assembly is referenced in the Core project.

At the root level of this folder I have added MyLdapAuthenticationSource.cs, as per the instructions.

The final step was to enable MyLdapAuthenticationSource.

I have added Configuration.Modules.ZeroLdap().Enable(typeof(MyLdapAuthenticationSource)); into the PreInitialize() method inside AbpProjectNameCoreModule.

But it doesn't work.

It cannot find ZeroLdap() in Configuration.Modules.

How do I get it to recognise the ZeroLdap() method?

Kind Regards, Tony

Showing 1 to 5 of 5 entries