Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-749

Doc: Security: Making intitially requested and secured page available for redirect after login

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.2.0
    • Documentation
    • None

    Description

      http://deltaspike.apache.org/documentation/security.html#_making_intitially_requested_and_secured_page_available_for_redirect_after_login

      In CDI Implementation to redirect the login to the first denied page:

      • change Usuario to User
      • why use char[] for password? Is that some security measure, to prevent interned Strings of passwords hanging around in memory? If so, that should be noted, otherwise it should be changed to String, it's confusing.

      In CDI and PL implementations:

      • the AdminAccessDecisionVoter should implement AccessDecisionVoter, not extend AbstractAccessDecisionVoter
      • I think the AdminAccessDecisionVoter should be agnostic of the view layer and therefore shouldn't inject ViewConfigResolver and shouldn't keep the denied page itself.

      Maybe the listener could handle the AccessDeniedException instead:

      Basic voter:

      AdminAccessDecisionVoter.java
      @SessionScoped //or @WindowScoped
      public class AdminAccessDecisionVoter extends AbstractAccessDecisionVoter {
      
          @Override
          protected void checkPermission(AccessDecisionVoterContext context, Set<SecurityViolation> violations) {
              // voting stuff
          }
      }
      

      The listener/holder/handler:

      AuthenticationListener.java
      @ExceptionHandler
      public class AuthenticationListener {
      
          @Inject ViewNavigationHandler viewNavigationHandler;
      
          @Inject ViewConfigResolver viewConfigResolver;
      
          private Class<? extends ViewConfig> deniedPage;
      
          public void rememberDeniedView(@BeforeHandles ExceptionEvent<ErrorViewAwareAccessDeniedException> evt) {
              deniedPage = viewConfigResolver.getViewConfigDescriptor(FacesContext.getCurrentInstance().getViewRoot().getViewId()).getConfigClass();
              evt.handledAndContinue();
          }
      
          public void handleLoggedIn(@Observes UserLoggedInEvent event) {
              if(deniedPage != null) {
                  viewNavigationHandler.navigateTo(deniedPage);
                  deniedPage = null;
              }
              viewNavigationHandler.navigateTo(Pages.Home.class);
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rsmeral Ron Smeral
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: