Skip to content
Snippets Groups Projects
Commit 767b2b0a authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Permit access to user with username 'anonymous'

parent 23b6d2dc
Branches
Tags
No related merge requests found
...@@ -27,6 +27,8 @@ public class AuthorizationAdviser { ...@@ -27,6 +27,8 @@ public class AuthorizationAdviser {
public void checkAuthorization(Authenticated authenticated, Object object) { public void checkAuthorization(Authenticated authenticated, Object object) {
User u = userService.getUser(SecurityContextHolder.getContext().getAuthentication()); User u = userService.getUser(SecurityContextHolder.getContext().getAuthentication());
if (u == null) throw new UnauthorizedException(); if (u == null) throw new UnauthorizedException();
// TODO: For unauthorized users e.g. after logout there is still a user object with username 'anonymous'
if (u.getUsername().equals("anonymous")) throw new UnauthorizedException();
} }
/** This method checks if the user is enlisted in current ARSnova session /** This method checks if the user is enlisted in current ARSnova session
......
...@@ -7,13 +7,11 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken; ...@@ -7,13 +7,11 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationToken; import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import com.github.leleuj.ss.oauth.client.authentication.OAuthAuthenticationToken; import com.github.leleuj.ss.oauth.client.authentication.OAuthAuthenticationToken;
import de.thm.arsnova.entities.User; import de.thm.arsnova.entities.User;
@Service
public class UserService implements IUserService { public class UserService implements IUserService {
@Override @Override
......
...@@ -77,5 +77,11 @@ ...@@ -77,5 +77,11 @@
init-method="startServer" destroy-method="stopServer" scope="singleton" init-method="startServer" destroy-method="stopServer" scope="singleton"
p:portNumber="${socketio.port}" p:hostIp="${socketio.ip}" p:useSSL="${security.ssl}" p:keystore="${security.keystore}" p:portNumber="${socketio.port}" p:hostIp="${socketio.ip}" p:useSSL="${security.ssl}" p:keystore="${security.keystore}"
p:storepass="${security.storepass}" /> p:storepass="${security.storepass}" />
<bean id="authorizationAdviser" class="de.thm.arsnova.aop.AuthorizationAdviser">
<property name="userService" ref="userService" />
</bean>
<bean id="userService" scope="singleton" class="de.thm.arsnova.services.UserService" />
</beans> </beans>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment