Skip to content

Commit

Permalink
[Core] Delay use of IUserRegistry since it may not be registered when
Browse files Browse the repository at this point in the history
HTTP server starts
  • Loading branch information
alexrobin committed Jan 10, 2024
1 parent bbb0cd6 commit 240332d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker;
import org.eclipse.jetty.server.SymlinkAllowedResourceAliasChecker;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
Expand Down Expand Up @@ -180,7 +180,7 @@ protected synchronized void doStart() throws SensorHubException
fileResourceContext.setResourceBase(config.staticDocsRootDir);

//fileResourceContext.clearAliasChecks();
fileResourceContext.addAliasCheck(new AllowSymLinkAliasChecker());
fileResourceContext.addAliasCheck(new SymlinkAllowedResourceAliasChecker(fileResourceContext));

handlers.addHandler(fileResourceContext);
getLogger().info("Static resources root is " + config.staticDocsRootUrl);
Expand All @@ -200,9 +200,9 @@ protected synchronized void doStart() throws SensorHubException
{
jettySecurityHandler = new ConstraintSecurityHandler();

// load user list
// create login service connected to OSH security manager
ISecurityManager securityManager = getParentHub().getSecurityManager();
OshLoginService loginService = new OshLoginService(securityManager.getUserRegistry());
OshLoginService loginService = new OshLoginService(securityManager);

if (config.authMethod == AuthMethod.BASIC)
jettySecurityHandler.setAuthenticator(new HttpLogoutWrapper(new BasicAuthenticator(), getLogger()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import org.eclipse.jetty.security.LoginService;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.security.Credential;
import org.sensorhub.api.security.ISecurityManager;
import org.sensorhub.api.security.IUserInfo;
import org.sensorhub.api.security.IUserRegistry;


public class OshLoginService implements LoginService
{
final ISecurityManager securityManager;
IdentityService identityService = new DefaultIdentityService();
IUserRegistry users;
//Map<String, UserIdentity>


public static class UserPrincipal implements Principal
Expand Down Expand Up @@ -73,9 +72,9 @@ public String getName()
}


public OshLoginService(IUserRegistry users)
public OshLoginService(ISecurityManager securityManager)
{
this.users = users;
this.securityManager = securityManager;
}


Expand Down Expand Up @@ -106,7 +105,7 @@ public UserIdentity login(String username, Object credentials, ServletRequest re
isCert = true;
}

IUserInfo user = users.get(username);
IUserInfo user = securityManager.getUserInfo(username);
if (user == null)
return null;

Expand Down

0 comments on commit 240332d

Please sign in to comment.