Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,6 @@
<url-pattern>/api/*</url-pattern>
</filter-mapping> -->

<!-- allow anonymous users -->
<!--
<filter>
<filter-name>AnonymousUserFilter</filter-name>
<filter-class>prerna.web.conf.AnonymousUserFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AnonymousUserFilter</filter-name>
<url-pattern>/api/*</url-pattern>
</filter-mapping>
-->

<!-- CAC FILTER -->
<!--
<filter>
Expand Down Expand Up @@ -485,23 +473,6 @@
-->
<!-- End Waffle -->

<!-- Allow Token Filter -->
<filter>
<filter-name>NoUserInSessionTrustedTokenFilter</filter-name>
<filter-class>prerna.web.conf.NoUserInSessionTrustedTokenFilter</filter-class>
<init-param>
<param-name>trustedTokenPrefix</param-name>
<param-value>sencha</param-value>
</init-param>
<init-param>
<param-name>trustedTokenDomain</param-name>
<param-value>*</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>NoUserInSessionTrustedTokenFilter</filter-name>
<url-pattern>/api/*</url-pattern>
</filter-mapping>
<!-- This is the main filter for security -->
<filter>
<filter-name>NoUserInSessionFilter</filter-name>
Expand Down Expand Up @@ -707,14 +678,6 @@
<param-name>admin-set-publisher</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>anonymous-users-allowed</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>anonymous-users-upload-data</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>use-logout-page</param-name>
<param-value>false</param-value>
Expand Down Expand Up @@ -746,9 +709,6 @@
<listener>
<listener-class>prerna.web.conf.UserDBLoader</listener-class>
</listener>
<listener>
<listener-class>prerna.web.conf.NoUserInSessionTrustedTokenListener</listener-class>
</listener>
<listener>
<listener-class>prerna.semoss.web.github.GitHubLifecycleListener</listener-class>
</listener>
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog-image-uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ and other formats are not accepted by these routes.
| Status | Meaning |
| --- | --- |
| 400 | Invalid ID, empty/corrupt image, invalid dimensions, missing `file`, or malformed multipart body |
| 401 | Missing session or anonymous user |
| 401 | Missing session |
| 403 | Resource is missing or the caller cannot edit it |
| 413 | File/request size limit exceeded, or multiple multipart parts supplied |
| 415 | Request is not multipart, or image format is unsupported |
Expand Down
2 changes: 1 addition & 1 deletion docs/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ A model usage limit is JSON: Unlimited, or rules that must all have usage left.

Only a model's owners, and admins in admin mode, set usage limits on it: a person's, a team's, public use and the model's total. Editors still add people and change the level of Read-Only and Editor people; their adds give no limit and their changes keep the current one. A change by an editor that leaves any other limit is refused with "Only owners can set usage limits".

These endpoints read and set limits that are not part of a grant. Anonymous sessions get `401` from each.
These endpoints read and set limits that are not part of a grant. Requests without a signed in user get `401` from each.

| Method and endpoint | Inputs / purpose | Who may call |
| --- | --- | --- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Response available(@Context HttpServletRequest req) {
} catch (IllegalAccessException e) {
classLogger.debug("Microsoft Graph availability was asked for without a session.", e);
}
if (user == null || !user.isLoggedIn() || user.isAnonymous()) {
if (user == null || !user.isLoggedIn()) {
return WebUtility.getResponse(Map.of(STATUS, ERROR, REASON, "user session is invalid"), 401);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ private static void loadConfig() {

// security is always enabled...
loadConfig.put("security", true);
loadConfig.put("anonymousUsers", AbstractSecurityUtils.anonymousUsersEnabled());
loadConfig.put("anonymousUserUploadData", AbstractSecurityUtils.anonymousUserUploadData());
// admin only for project actions
loadConfig.put("adminOnlyProjectAdd", AbstractSecurityUtils.adminOnlyProjectAdd());
loadConfig.put("adminOnlyProjectDelete", AbstractSecurityUtils.adminOnlyProjectDelete());
Expand Down Expand Up @@ -311,7 +309,7 @@ private static Map<String, Object> getConfiguration(@Context HttpServletRequest
// from the scopes it asks for, so a client can tell which apps can work before
// it calls them. only whether each app can work is sent, never the scopes, and
// only to a user signed in to the platform
if (user != null && user.isLoggedIn() && !user.isAnonymous()) {
if (user != null && user.isLoggedIn()) {
myConfiguration.put("connectorAccess", ConnectorScopeAccess.getConnectorAccess());
}
// themes
Expand Down Expand Up @@ -375,8 +373,8 @@ public Response fetchCsrf(@Context HttpServletRequest request, @Context HttpServ
* {@code @Consumes}/{@code @Produces} content types.
* <p>
* Resources whose simple class name starts with {@code "Admin"} are only
* included when the calling user is logged in and an admin. Anonymous and
* non-admin users get the rest of the catalog without those entries.
* included when the calling user is logged in and an admin. Other callers get
* the rest of the catalog without those entries.
*
* @param request the incoming HTTP request (used only to prefix the
* application context path on each path so callers see real
Expand All @@ -388,8 +386,8 @@ public Response fetchCsrf(@Context HttpServletRequest request, @Context HttpServ
@Path("/endpoints")
@Produces("application/json")
public Response listEndpoints(@Context HttpServletRequest request, @Context Application application) {
// admin gating: anonymous users and non-admin logged-in users do not
// see endpoints from resources whose simple class name starts with
// admin gating: callers who are not a logged-in admin do not see
// endpoints from resources whose simple class name starts with
// "Admin" (e.g. AdminUserAuthorizationResource).
boolean includeAdminResources = false;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/prerna/semoss/web/services/local/NameServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ public Response agentRunStreaming(MultivaluedMap<String, String> form, @Context
}
HttpSession session = request.getSession(false);
User user = session == null ? null : (User) session.getAttribute(Constants.SESSION_USER);
if (user == null || user.isAnonymous()) {
if (user == null) {
Map<String, Object> errorRet = new HashMap<>();
errorRet.put("errorMessage", "Agent run streaming requires an authenticated user");
return WebUtility.getResponseNoCache(errorRet, 401);
Expand Down
27 changes: 2 additions & 25 deletions src/prerna/semoss/web/services/local/ResourceUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public interface AdminCall<T> {

/**
* Runs a call for the signed in user and turns its outcome into the response:
* 200 with its result, 401 for a missing or anonymous session, 403 for a user who
* may not do it, 400 for a bad request and 500 for anything else. Errors carry
* 200 with its result, 401 for a missing session, 403 for a user who may not do
* it, 400 for a bad request and 500 for anything else. Errors carry
* {@link Constants#ERROR_MESSAGE}, and unexpected ones
* {@link Constants#TECH_ERROR_MESSAGE} too. Every outcome is logged with the
* endpoint, such as {@code POST /Monolith/api/auth/group/addGroupMember}, the
Expand All @@ -185,25 +185,6 @@ public interface AdminCall<T> {
* @return the response
*/
public static Response respond(HttpServletRequest request, String action, UserCall call) {
return respond(request, action, false, call);
}

/**
* {@link #respond} for a call that only reads, which an anonymous session, such
* as a visitor to a public app, may make too. A call that changes anything uses
* {@link #respond}, which answers anonymous sessions with 401.
*
* @param request the request, whose session holds the user
* @param action what the call does, for the logs, such as
* {@code "read their permission on project 123"}
* @param call the call
* @return the response
*/
public static Response respondAllowingAnonymous(HttpServletRequest request, String action, UserCall call) {
return respond(request, action, true, call);
}

private static Response respond(HttpServletRequest request, String action, boolean allowAnonymous, UserCall call) {
String endpoint = request.getMethod() + " " + request.getRequestURI();
User user;
try {
Expand All @@ -212,10 +193,6 @@ private static Response respond(HttpServletRequest request, String action, boole
classLogger.warn("[{}] A request without a signed in user tried to {}", endpoint, action);
return errorResponse("User session is invalid", 401);
}
if (user.isAnonymous() && !allowAnonymous) {
classLogger.warn("[{}] An anonymous user tried to {}", endpoint, action);
return errorResponse("User session is invalid", 401);
}

String userName = User.getSingleLogginName(user);
try {
Expand Down
12 changes: 5 additions & 7 deletions src/prerna/semoss/web/services/local/UserResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import prerna.auth.SyncUserAssetsThread;
import prerna.auth.User;
import prerna.auth.external.ExternalAuthorizationHelper;
import prerna.auth.utils.AbstractSecurityUtils;
import prerna.auth.utils.SecurityAPIUserUtils;
import prerna.auth.utils.SecurityAdminUtils;
import prerna.auth.utils.SecurityExternalConnectorsUtils;
Expand Down Expand Up @@ -328,7 +327,6 @@ public static void addAccessToken(AccessToken token, HttpServletRequest request,
SecurityUserUtils.loadUserMetadata(token);

semossUser.setAccessToken(token);
semossUser.setAnonymous(false);

session.setAttribute(Constants.SESSION_USER, semossUser);
WebUtility.loggingContextLoginEvent(session);
Expand Down Expand Up @@ -1379,7 +1377,7 @@ public Response loginNative(@Context HttpServletRequest request, @Context HttpSe
User user = null;
if (session != null) {
user = (User) session.getAttribute(Constants.SESSION_USER);
if (!AbstractSecurityUtils.anonymousUsersEnabled() && user != null && user.getLogins().isEmpty()) {
if (user != null && user.getLogins().isEmpty()) {
session.invalidate();
}
}
Expand All @@ -1395,7 +1393,7 @@ public Response loginNative(@Context HttpServletRequest request, @Context HttpSe
HttpSession session = request.getSession(false);
if (session != null) {
User user = (User) session.getAttribute(Constants.SESSION_USER);
if (!AbstractSecurityUtils.anonymousUsersEnabled() && user != null && user.getLogins().isEmpty()) {
if (user != null && user.getLogins().isEmpty()) {
session.invalidate();
}
}
Expand Down Expand Up @@ -1460,7 +1458,7 @@ public Response loginLDAP(@Context HttpServletRequest request, @Context HttpServ
HttpSession session = request.getSession(false);
if (session != null) {
User user = (User) session.getAttribute(Constants.SESSION_USER);
if (!AbstractSecurityUtils.anonymousUsersEnabled() && user != null && user.getLogins().isEmpty()) {
if (user != null && user.getLogins().isEmpty()) {
session.invalidate();
}
}
Expand All @@ -1475,7 +1473,7 @@ public Response loginLDAP(@Context HttpServletRequest request, @Context HttpServ
HttpSession session = request.getSession(false);
if (session != null) {
User user = (User) session.getAttribute(Constants.SESSION_USER);
if (!AbstractSecurityUtils.anonymousUsersEnabled() && user != null && user.getLogins().isEmpty()) {
if (user != null && user.getLogins().isEmpty()) {
session.invalidate();
}
}
Expand Down Expand Up @@ -1535,7 +1533,7 @@ public Response changeADPassword(@Context HttpServletRequest request, @Context H
HttpSession session = request.getSession(false);
if (session != null) {
User user = (User) session.getAttribute(Constants.SESSION_USER);
if (!AbstractSecurityUtils.anonymousUsersEnabled() && user != null && user.getLogins().isEmpty()) {
if (user != null && user.getLogins().isEmpty()) {
session.invalidate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Response getEngines(@Context HttpServletRequest request, @QueryParam("eng
List<String> engines = WebUtility.inputSanitizer(engineFilter);
List<String> types = WebUtility.inputSanitizer(engineTypes);
List<String> keys = WebUtility.inputSanitizer(metaKeys);
return ResourceUtility.respondAllowingAnonymous(request, "list the engines they can access", user -> {
return ResourceUtility.respond(request, "list the engines they can access", user -> {
MyEnginesReactor reactor = new MyEnginesReactor();
reactor.In();
Insight temp = new Insight();
Expand Down Expand Up @@ -164,7 +164,7 @@ public Response getEngines(@Context HttpServletRequest request, @QueryParam("eng
@Produces("application/json")
@Path("getEngines")
public Response getEnginesPOST(@Context HttpServletRequest request) {
return ResourceUtility.respondAllowingAnonymous(request, "list the engines they can access", user -> {
return ResourceUtility.respond(request, "list the engines they can access", user -> {
MyEnginesReactor reactor = new MyEnginesReactor();
reactor.In();
Insight temp = new Insight();
Expand Down Expand Up @@ -257,7 +257,7 @@ public Response getUserEnginePermission(@Context HttpServletRequest request,
@QueryParam("engineId") String engineId) {
String engine = WebUtility.inputSanitizer(engineId);
String action = "read their permission on engine " + engine;
return ResourceUtility.respondAllowingAnonymous(request, action, user -> {
return ResourceUtility.respond(request, action, user -> {
String permission = SecurityEngineUtils.getActualUserEnginePermission(user, engine);
if (permission == null) {
// are you discoverable?
Expand Down Expand Up @@ -294,7 +294,7 @@ public Response getEngineUsers(@Context HttpServletRequest request, @QueryParam(
String term = WebUtility.inputSQLSanitizer(searchTerm);
String level = WebUtility.inputSanitizer(permission);
String searchParam = term != null ? term : member;
return ResourceUtility.respondAllowingAnonymous(request, "list the users of engine " + engine, user -> {
return ResourceUtility.respond(request, "list the users of engine " + engine, user -> {
List<Map<String, Object>> members = SecurityEngineUtils.getEngineUsers(user, engine, searchParam, level,
limit, offset);
long totalMembers = SecurityEngineUtils.getEngineUsersCount(user, engine, searchParam, level);
Expand Down Expand Up @@ -595,7 +595,7 @@ public Response getEngineUsersNoCredentials(@Context HttpServletRequest request,
@QueryParam(MicrosoftGraphUserLookup.LOOKUP_PARAM) String msGraphLookup) {
String engine = WebUtility.inputSanitizer(engineId);
String term = WebUtility.inputSQLSanitizer(searchTerm);
return ResourceUtility.respondAllowingAnonymous(request, "find people to add to engine " + engine, user -> {
return ResourceUtility.respond(request, "find people to add to engine " + engine, user -> {
// when the directory is not used
// then we will look at our security db
if (!MicrosoftGraphUserLookup.useDirectory(msGraphLookup)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
* act as an ordinary user; admins manage every custom group under
* {@code /auth/admin/group}. The owner of a project or engine can see who
* manages a custom group before they give it access.
* {@link SecurityGroupManagerUtils} checks who may do what; anonymous sessions
* can do nothing here.
* {@link SecurityGroupManagerUtils} checks who may do what.
*/
@Path("/auth/group")
@PermitAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public Response getGroupAppPermission(@Context HttpServletRequest request, @Quer
String groupType = AuthProvider.getProviderLabel(WebUtility.inputSanitizer(type));
String engine = WebUtility.inputSanitizer(appId);
String group = WebUtility.inputSQLSanitizer(groupId);
return ResourceUtility.respondAllowingAnonymous(request,
"read the permission of group " + group + " on engine " + engine, user -> {
return ResourceUtility.respond(request, "read the permission of group " + group + " on engine " + engine,
user -> {
Integer permissionCode = SecurityGroupEngineUtils.getGroupDatabasePermission(
ValueUtils.requireNonBlank(group, GROUP_ID_REQUIRED),
ValueUtils.requireNonBlank(groupType, GROUP_TYPE_REQUIRED),
Expand Down Expand Up @@ -194,19 +194,18 @@ public Response getAllGroupsWithAccessToEngine(@Context HttpServletRequest reque
@QueryParam("engineId") String engineId, @QueryParam("limit") long limit,
@QueryParam("offset") long offset) {
String engine = WebUtility.inputSanitizer(engineId);
return ResourceUtility.respondAllowingAnonymous(request, "list the groups with access to engine " + engine,
user -> {
if (engine == null || engine.isEmpty()) {
throw new IllegalArgumentException("Must define the engineId");
}
List<Map<String, Object>> groups = SecurityGroupEngineUtils.getGroupsWithAccessToEngine(user,
engine, limit, offset);
long totalGroups = SecurityGroupEngineUtils.getNumGroupsWithAccessToEngine(user, engine);
Map<String, Object> ret = new HashMap<>();
ret.put("totalGroups", totalGroups);
ret.put("groups", groups);
return ret;
});
return ResourceUtility.respond(request, "list the groups with access to engine " + engine, user -> {
if (engine == null || engine.isEmpty()) {
throw new IllegalArgumentException("Must define the engineId");
}
List<Map<String, Object>> groups = SecurityGroupEngineUtils.getGroupsWithAccessToEngine(user, engine, limit,
offset);
long totalGroups = SecurityGroupEngineUtils.getNumGroupsWithAccessToEngine(user, engine);
Map<String, Object> ret = new HashMap<>();
ret.put("totalGroups", totalGroups);
ret.put("groups", groups);
return ret;
});
}

/**
Expand All @@ -228,8 +227,8 @@ public Response getAvailableGroupsForEngine(@Context HttpServletRequest request,
@QueryParam("limit") long limit, @QueryParam("offset") long offset) {
String engine = WebUtility.inputSanitizer(engineId);
String term = WebUtility.inputSQLSanitizer(searchTerm);
return ResourceUtility.respondAllowingAnonymous(request,
"list the groups that can be given access to engine " + engine, user -> {
return ResourceUtility.respond(request, "list the groups that can be given access to engine " + engine,
user -> {
if (engine == null || engine.isEmpty()) {
throw new IllegalArgumentException("Must define the engineId");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Response getGroupInsightPermission(@Context HttpServletRequest request,
String groupType = AuthProvider.getProviderLabel(WebUtility.inputSQLSanitizer(type));
String insight = WebUtility.inputSQLSanitizer(insightId);
String group = WebUtility.inputSQLSanitizer(groupId);
return ResourceUtility.respondAllowingAnonymous(request,
return ResourceUtility.respond(request,
"read the permission of group " + group + " on insight " + insight + " of project " + project, user -> {
Integer permissionCode = SecurityGroupInsightsUtils.getGroupInsightPermission(
ValueUtils.requireNonBlank(group, GROUP_ID_REQUIRED),
Expand Down
Loading
Loading