merge with branch issue-384

This commit is contained in:
Sebastian Sdorra
2013-04-26 14:46:37 +02:00
17 changed files with 65 additions and 25 deletions

View File

@@ -183,7 +183,7 @@ public final class PermissionUtil
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated())
if (subject.isAuthenticated() || subject.isRemembered())
{
String username = subject.getPrincipal().toString();

View File

@@ -69,12 +69,33 @@ public final class Tokens
* @param username username of the user to authenticate
* @param password password of the user to authenticate
*
* @return
* @return authentication token
*/
public static AuthenticationToken createAuthenticationToken(
HttpServletRequest request, String username, String password)
{
return new UsernamePasswordToken(username, password,
return createAuthenticationToken(request, username, password, false);
}
/**
* Build an {@link AuthenticationToken} for use with
* {@link Subject#login(org.apache.shiro.authc.AuthenticationToken)}.
*
*
* @param request servlet request
* @param username username of the user to authenticate
* @param password password of the user to authenticate
* @param rememberMe true to remember the user across sessions
*
* @return authentication token
*
* @since 1.31
*/
public static AuthenticationToken createAuthenticationToken(
HttpServletRequest request, String username, String password,
boolean rememberMe)
{
return new UsernamePasswordToken(username, password, rememberMe,
request.getRemoteAddr());
}
}

View File

@@ -87,7 +87,7 @@ public final class SecurityUtil
{
Subject subject = SecurityUtils.getSubject();
if (!subject.isAuthenticated())
if (!subject.hasRole(Role.USER))
{
throw new ScmSecurityException("user is not authenticated");
}

View File

@@ -156,7 +156,7 @@ public class BasicAuthenticationFilter extends HttpFilter
}
}
}
else if (subject.isAuthenticated())
else if (subject.isAuthenticated() || subject.isRemembered())
{
if (logger.isTraceEnabled())
{

View File

@@ -65,6 +65,7 @@ import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import sonia.scm.security.Role;
/**
* Abstract http filter to check repository permissions.
@@ -255,7 +256,7 @@ public abstract class PermissionFilter extends HttpFilter
private void sendAccessDenied(HttpServletResponse response, Subject subject)
throws IOException
{
if (subject.isAuthenticated())
if (subject.hasRole(Role.USER))
{
response.sendError(HttpServletResponse.SC_FORBIDDEN);
}