coreyauger / Neo4JMembershipProvider

asp.net Neo4J Membership Provider
MIT License
4 stars 4 forks source link

Issue on private string EncodePassword(string password) #5

Closed shainefisher closed 9 years ago

shainefisher commented 9 years ago

Just a quick one as I know you are no longer developing this, When I have requiresQuestionAndAnswer="false" in my web.config file it was failing to create a new user, which I thought was odd, so I ran the debugger and found that EncodePassword was being called 3 times, the first time was with the password the user required the other 2 were null values, I will assume one of these was the security question answer.

I just added this line to the start of EncodePassword(string password)

password = string.IsNullOrEmpty(password) ? "somerandomstring" : password;

and it works perfectly, just thought you should have it here in case anyone else sees this issue. Neo4j 2.2.2, Asp.net 4.5, IIS 7.5, WebForm project.

Also wondering, even if it just floating in a non developed state where did you get to with the RolesProvider? Or did anyone actually pick it up and come up with anything?

Thanks

pcmantinker commented 9 years ago

If you check this pull request, support for roles was merged in March 2014. I was the original author of the pull request. I recommend you look at Neo4j.AspNet.Identity going forward though.

shainefisher commented 9 years ago

The issue I had with Neo4j.AspNet.Identity was working out how to migrate from my custom membership provider to it, at least with the Neo4JMembership it was a small change and I could do that without interfering with my WebService projects too much. I am looking into it though, thanks for the link :)

shainefisher commented 9 years ago

@pcmantinker I have a quick question, membership works perfectly, no issues at all, but when I enable roles in the web.config using:

<roleManager enabled="true" defaultProvider="Neo4JRoleProvider">
  <providers>
    <clear />
    <add name="Neo4JRoleProvider" type="Nextwave.Neo4J.Membership.Neo4JRolesProvider" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</roleManager>

I launch the webadmin, go to security and it's says I have 1 user and 0 roles, which is correct. When I click on either add user or add role I get:

The following message may help in diagnosing the problem: Type 'Neo4jClient.NeoException' in assembly 'Neo4jClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_users_adduser_aspx.PopulateCheckboxes() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\Security\Users\addUser.aspx:line 28 at ASP.security_users_adduser_aspx.Page_Load() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\Security\Users\addUser.aspx:line 22 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

If I disable roles again it works, but to be honest I have no idea where to start.

IIS 7.5, .Net 4.5, Blank project, with a webserviceasmx sitting in the root, directory secured with SSL and using basic auth to secure (access using the user that is stored in the Neo4j Database)

Please take a quick look and see if you have any ideas :)

shainefisher commented 9 years ago

@pcmantinker traced down the issue.

Neo4jClient.NeoException: SyntaxException: roles not defined (line 2, column 16 (offset: 34)) "RETURN collect(roles)" ^ at Neo4jClient.GraphClient.Neo4jClient.IRawGraphClient.ExecuteGetCypherResults[TResult](CypherQuery query) in c:\Users\Sticky Kiwi\Documents\Visual Studio 2012\Projects\Sticky Kiwi\Neo4jClient\GraphClient.cs:line 803 at Neo4jClient.Cypher.CypherFluentQuery1.get_Results() in c:\Users\Sticky Kiwi\Documents\Visual Studio 2012\Projects\Sticky Kiwi\Neo4jClient\Cypher\CypherFluentQueryTResult.cs:line 51 at Nextwave.Neo4J.Membership.Neo4JRolesProvider.GetAllRoles() in c:\Users\Sticky Kiwi\Documents\Visual Studio 2012\Projects\Sticky Kiwi\Neo4JMembershipProvider\Neo4JRoleProvider.cs:line 175 at System.Web.Security.Roles.GetAllRoles() at com.stickykiwi.services.portal.WebService1.HelloWorld() in c:\Users\Sticky Kiwi\Documents\Visual Studio 2012\Projects\Sticky Kiwi\com.stickykiwi.services.portal\WebService1.asmx.cs:line 24 ^

I added Roles.GetAllRoles(); to a webservice and hit the debugger, this is where it fails. But that is all I got.

coreyauger commented 9 years ago

Hi @shainefisher

If you take a look at the Neo4JRoleProvider.cs

You will see the Query in there.

Notice the Match name is "role" .. and the results returns "roles" plural .. I suspect this is your problem ... try and change this and test it... if it corrects the problem you can send me a pull request and I will merge the fix.

Thanks.


       public override string[] GetAllRoles()
        {
            var roleSearch = _neoClient.Cypher
                .Match("(role:Role)")
                .Return(roles => roles.CollectAs<Role>())
                .Results;

            List<string> roleList = new List<string>();
            foreach (var r in roleSearch)
            {
                roleList.Add(r.FirstOrDefault().Data.RoleName);
            }

            return roleList.ToArray();
        }
shainefisher commented 9 years ago

public override string[] GetAllRoles() { var roleSearch = _neoClient.Cypher .Match("(role:Role)") .Return(role => role.CollectAs()) .Results;

        List<string> roleList = new List<string>();
        foreach (var r in roleSearch)
        {
            roleList.Add(r.FirstOrDefault().Data.RoleName);
        }

        return roleList.ToArray();
    }

This works, but it only displays a single Role in the webadmin, but it works and this is good enough for me. So thank you, and I am going to close off this issue.

You were an immense help, really appreciate it.