GithubHelp home page GithubHelp logo

kahanu / security-guard Goto Github PK

View Code? Open in Web Editor NEW
59.0 59.0 24.0 11.2 MB

A complete ASP.NET MVC Membership Management system using the ASP.NET Membership System to be deployed using NuGet. Now available for MVC 4!!!

Pascal 6.08% C# 71.44% Puppet 3.17% CSS 11.21% JavaScript 3.50% ASP 4.60%

security-guard's People

Contributors

kahanu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

security-guard's Issues

Login/Registration errors not shown

If you have a general model error on login or registration, it doesn't get shown, because you're using Redirect instead of calling View(). I have modified my local code to do so, which also requires you to refresh the model again.

Unscoped DOM calls in JavaScript could be a problem with customized layouts.

I am using SecurityGuard in one of my applications and for a consistent look and feel, I customized the _SecurityGuardLayoutPage.cshtml with the layout and styles that I wanted to use. Well viewing the roles in security, I found that every time that I selected a role in the drop-down list, my navigation would disappear. So I looked at the source code and found that in the Views\Roles\Index.cshtml, there is a client-side javascript method "OnGetUsersInRolesSuccess()" that has a call to:

$("li").remove();

This will remove all

  • items from the DOM instead of simply clearing the
      list that it was intended to clear. I think that a better approach would be the one I took where all calls are scoped to the ui elemented intended so that users can customize the pages / themes without impacting the client-side functionality.

      I changed all un-scoped calls like the one above to:
      /***********************************************
      * Begin Get Users In Role Functions
      ***********************************************/

          // users-in-role-div
          // roles ul DOM element
      
          var usersInRoleDiv = $("#users-in-role-div");
          var ul = $("#users-in-role-div ul");
      

      function OnGetUsersInRoleSuccess(data) {
      //this call should be scoped
      //$("li").remove();
      ul.empty();

              if (data == "") {
                  ul.append("<li>No user(s).</li>");
              } else {
                  $.each(data, function (index, item) {
                      ul.append("<li><a href=\"/SecurityGuard/Membership/Update/" + item + "\">" + item + "</a></li>");
                  });
              }
          }
      

      I would have requested a pull but I thought that this was an easy enough fix. Great work though...saves alot of time when it comes to managing users.

  • Can't access SecurityGuard Area

    Hi,

    I already added a user in "SecurityGuard" role but when I try to access something at SecurityGuard area (Dashboard, Membership and Role) I'm redirected to login page.

    Do you know what are happening?

    Thanks.

    Navigating to a user page with special @ character

    UserCase: 1) user registers an account with his mail [email protected] in UserName field.
    2) I can't to visit a page with url like http://host/SecurityGuard/Membership/Update/hell--00%40mail.ru
    I got a 404 not found page.
    A '@' symbol is restricted and it has encoded. Later In a controller 'Membership' a string(hell--00%40mail.ru) would decoded to [email protected] before quering a user.
    The second solution is to restrict usernames which looks like email at all.

    Not using One ASP.NET Identity

    MembershipProvider is an abandoned system now; Microsoft is now pushing their ASP.NET Identity solution (http://asp.net/identity).

    SecurityGuard still looks to be the most complete user management system available right now for ASP.NET MVC. But unfortunately it's not particularly useful for greenfield projects where ASP.NET Identity is used instead of MembershipProvider.

    Are there plans to make a migration? (It may require a rewrite of most of the back-end.)

    CreateUser action appears to not properly verify Password and ConfirmPassword match

    I noticed today that I could create a user even if I didn't match the passwords. It appears it is checking it at some level because I was able to fix it by adding this to the top of MembershipController.CreateUser:
    if (model.Password != model.ConfirmPassword)
    return View(model);
    I didn't have to set an error message because when it renders the view it puts in a message indicating that the passwords don't match.

    Note: I am not using the latest version from NuGet. I customized it way too much to be able to update from NuGet. Forgive me if this is something you've already fixed. I checked the issue list and didn't see it in there.

    links to user details under Users in Role in /SecurityGuard/Role don't work

    I had some problems with bad user-links below "Users In Role" in /SecurityGuard/Role

    I think this is because I'm using a virtual directory.

    I changed line 223 in \Areas\SecurityGuard\Views\Role\Index.cshtml from:

    ul.append("<li><a href=\"/SecurityGuard/Membership/Update/" + item + "\">" + item + "</a></li>");
    

    to:

    ul.append("<li><a href=\"Membership/Update/" + item + "\">" + item + "</a></li>");
    

    Not sure if this will work in all cases but hope that helps.

    Ambiguous CompareAttribute in Security Guard 1.0.3

    I'm experiencing one compilation issue with Security Guard 1.0.3, after having installed it into my ASP.NET MVC 4 (RC) project via NuGet. In ChangePasswordViewModel.cs and RegisterViewModel.cs, the CompareAttribute references are ambiguous since they can be resolved to either System.ComponentModel.DataAnnotations or System.Web.Mvc. I take it the intended namespace is System.Web.Mvc?

    Forgot Password Fails If Invalid Email Address Is Entered

    When completing forgot password. If the user enters an unregistered email address then the application errors. The ForgotPassword action should do something like this:

            [HttpPost]
            public ActionResult ForgotPassword(ForgotPasswordViewModel model) {
    
                      // Get the userName by the email address
                      string userName = membershipService.GetUserNameByEmail(model.Email);
    
                      // confirm that the username is not null i.e. the username was found by email.
                      if(!string.IsNullOrEmpty(userName)) {
    
                               // Get the user by the userName
                               MembershipUser user = membershipService.GetUser(userName);
    
                               // if(user != null) {
    
                                        ..... execute the code as normal
                              }
                       }
             }
    

    SecurityGuard.MVC4 1.0.3 - Trouble with removing yourself from the administrator role

    I'm using SecurityGuard.MVC4 1.0.3 in combination with ASP.NET MVC 4. As a test, I logged in as admin and via the Security Guard dashboard I removed myself from the 'Administrator' role (having renamed the 'SecurityGuard' role to this), before I then tried to re-grant the role to myself. This led to an error in Security Guard, where I was prompted with a dialog notifying me of a syntax error: '<'. So I refreshed the page, and I was no longer in the Administrator role, and correspondingly I was denied access to the Security Guard dashboard.

    Do you think there should be some sane way of handling this scenario in Security Guard? For instance, deny removing the last administrative user (in whichever role authorizes access to Security Guard) or ask for confirmation that you're sure you wish to remove yourself from the role in question?

    SG create SQLExpressDatabase

    Dear kahanu
    i used the security guard in my mvc3 application
    it works good in my vs2010 , after i published the application and try to test in my iss i understand that when i want to view security guard area in my website it tries to ceate a sqlexpress database , i checked my project and see the App_Data foldr with a ASPNETDB.MDF named file,i copied this file in my iss and the website works fine!
    now i upload this application to a windows server 2008 R2 host and an error occur,this error is about the sqlExpress, i want to know is there any way to force SG not to create SQLexpress database ?
    the error is this : "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
    "
    my connection string works fine and sets to the correct database
    thank you
    Best regards

    SQLExpress connection?

    In an MVC4 clean project, Internet template, with initialized LocalDB membership database, SG treis to create a new SQLexpress instance and fails.
    Any suggestions?

    Log On returning JsonLogOn view result

    When I click the "Log In" link, enter my username and password in the dialog that appears, and click "Log On" I am presented with the "success" and "returnUrl" JSON, but not redirected to the home view as I would have expected.

    SGAccountController LogOn action method

    This action method returns the empty view instead of the model in case of a failed login attempt.

    This:

    // If we got this far, something failed, redisplay form
    return RedirectToAction("LogOn");
    

    Should be:

    // If we got this far, something failed, redisplay form
    return View(model);
    

    This is important so that the errors appear in the view. Today the errors are being hidden.

    Application Management

    Hi one of the best things of this kind of Wrappers around the membership technology will be if can be managed also the applications, i mean could create applications, but most important can users be associated with applications to be able to manage a central repository as asp.net membership from this project.

    Thanks

    Change Password

    Hi
    I believe the Change Password link is missing. One can find it using /SGAccount/ChangePassword but maybe there should a page that manage user details and lets her change the password...

    Problem Navigating Users with special characters in

    When navigating between users it doesn't work if the user has a full stop (period) in the user name, because you cant put them in the url string...

    /SecurityGuard/Membership/Update/phil.hey

    Maybe it would be better to post the username.

    library script loading

    In SG view jquery is loaded like this:
    <script src="@Url.Content("~/Content/SecurityGuard/scripts/jquery.validate.min.js")" type="text/javascript"></script>

    but the views created by new mvc 4 internet template use:
    @section Scripts { @Scripts.Render("~/bundles/jqueryval") }

    Would it be better to use the second form?

    _LogOnPartial error

    i am using mvc4 in vs2010
    when i use this line in my
    Hello, @Html.ActionLink(User.Identity.Name, "Manage", "SGAccount", routeValues: null, htmlAttributes: new { @Class = "username", title = "Manage" })!
    i got error when i select the link .
    i change to this line
    Hello, @Html.ActionLink(User.Identity.Name, "Update", "Membership", routeValues: new { area = "SecurityGuard" , userName = User.Identity.Name }, htmlAttributes: new { @Class = "username", title = "Manage" })!
    and it is work
    way?

    i cant see dashboard view

    hi! i did the tutorial of security guard mvc4 for VS 2012, and I cant see de dashboard view.. besides I can't access to role manager...

    Missing Gifs

    The following gifs referenced in the pagination.css are not in the images folder
    images/pag_bg.gif
    images/prev.gif
    images/next.gif
    images/go.gif

    Manage View missing

    Just installed the version 1.0.8 from NuGet (Package-Install SecurityGuard.MVC4), and the Manage views (both aspx and cshtml) seem to be missing from the "Views/SGAccount" directory.

    This obviously trigger errors are there are references to that View (notably in _LoginPartial.cshtml).
    2012-12-21 14_21_51-HomeNetworking - Microsoft Visual Studio Express 2012 for Web

    Manage Users page and Radio button javascript functions

    This code:

    
            $(".userRadio").click(function () {
                // Get the value of the clicked radio button
                // which is the username.
                var username = $(this).val();
    
                // Get a reference to the "href" of the link.
                var href = anchor.attr("href");
    
                // Concatenate the existing href value with the username
                var newHref = href + "/" + username;
    
                // Replace the existing href value with the new one
                anchor.attr("href", newHref);
    
                // Remove the disabled attribute on the 
                // Grant Roles to User link
                anchor.removeAttr("disabled");
            });
    

    Should be:

            $(".userRadio").click(function () {
                // Get the value of the clicked radio button
                // which is the username.
                var username = $(this).val();
    
                // Get a reference to the "href" of the link.
                var href = '@Url.Action("GrantRolesToUser", "Membership")'
    
                // Concatenate the existing href value with the username
                var newHref = href + "/" + username;
    
                // Replace the existing href value with the new one
                anchor.attr("href", newHref);
    
                // Remove the disabled attribute on the 
                // Grant Roles to User link
                anchor.removeAttr("disabled");
            });
    

    Why? Because when you select different users successively, the href will concatenate the user names, for example:

    Clicked user leniel:

    http://localhost:8087/SecurityGuard/membership/GrantRolesToUser/leniel

    Now I selected user tester after having selected user leniel:

    http://localhost:8087/users/membership/GrantRolesToUser/leniel/tester

    Can you spot the problem? The route breaks because it's expecting only 1 userName according to this route:

                context.MapRoute("Membership",
                    "users/membership/{action}/{username}",
                    new { controller = "Membership", username = UrlParameter.Optional }
                    ); 
    

    Total user count on Dashboard is incorrect

    I noticed that the dashboard showed 20 users total for my site and there are a lot more than that. I changed the existing code in DashboardController's Index action from:
    viewModel.TotalUserCount = membershipService.GetAllUsers().Count.ToString();

    and replaced it with:
    int total;
    membershipService.GetAllUsers(0, 1, out total);
    viewModel.TotalUserCount = total.ToString();

    Now it shows over 300 users as it should. I didn't try to dig into why the parameterless version doesn't return the right number.

    Clean up

    Hi
    It would be nice if the wiki could also mention what could be cleaned from a MVC 4 internet template project after Security Guard installation...

    2 viewmodels have ambiguous reference exception on build

    Clean MVC 4 project. Added SG via Nuget. Modifying according to Wiki.
    Build Error:
    'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute'

    Changed line 25 in RegisterViewModel
    to: System.ComponentModel.DataAnnotations.Compare

    and line 21 in ChangePasswordViewModel
    to: System.ComponentModel.DataAnnotations.Compare

    Clean build

    Choice based on this StackOverflow
    http://stackoverflow.com/q/10668948
    comment by Vinney K:

    So, looking at the MSDN documentation and doing a literal comparison of the two classes, I noticed both classes are derived from System.ComponentModel.DataAnnotations.ValidationAttribute. In fact, the classes are almost exactly the same. The only notable difference is that the MVC version also implements IClientValidatable which adds the following properties:
    •FormatPropertyForClientValidation - Formats the property for client validation by prepending an asterisk () and a dot.*
    •GetClientValidationRules - Gets a list of compare-value client validation rules for the property using the specified model metadata and controller context.

    As for which class you should you, if the model will be directly bound to a view, use the MVC version so that you can take advantage of the client-side validation. However, if you're using ViewModels, you can stick with the ComponentModel class and avoid the unnecessary overhead of the additional properties. Your call!

    Customize Security Guard Membership Problem

    Hello Everyone,

    I use Security Guard Membership for MVC3

    The scenario is i want to create a CMS for administrator, when admin go to url e.g: site.com/admin . It will go to dashboard as default if admin logined otherwise URL will go to login page for admin to login. And i also want to create a login page for user who want to buy some thing from my site.

    1. How can i create 2 login page for admin and for user ? when admin go to some URL in CMS, The site will go to login page for admin. And if the client want to do some thing like order goods ... they are required to login and the site will go to login page for them. Im so confused and get stuck in this.

    2.Can i use implementing method create user of membership to add user for the client ?

    Please give me suggestions, thanks in advance !

    Posting to SGAccount LogOff results in 404

    LogOff works fine when requested via GET, but throws a 404 on POST.

    To fix this I changed \Controllers\SGAccountController.cs line 102 from:

    [HttpGet]
    public virtual ActionResult LogOff()
    

    to:

    [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
    public virtual ActionResult LogOff()
    

    I hope that helps.

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.