Commit 9506b3c3 authored by Denis's avatar Denis Committed by Denis Ligin

Fixed filtering in /api/documents/*

parent f78e1cd5
Pipeline #373 failed with stage
...@@ -36,6 +36,7 @@ public class SecurityContextUtils { ...@@ -36,6 +36,7 @@ public class SecurityContextUtils {
.map(GrantedAuthority::getAuthority) .map(GrantedAuthority::getAuthority)
.map(role -> role.replace("ROLE_", "")) .map(role -> role.replace("ROLE_", ""))
.filter(role -> role.contains(PROJECT_ROLE_SPLITTER)) .filter(role -> role.contains(PROJECT_ROLE_SPLITTER))
.filter(role -> !role.contains("gitlab_"))
.collect(Collectors.toMap( .collect(Collectors.toMap(
role -> role.split(PROJECT_ROLE_SPLITTER)[0], role -> role.split(PROJECT_ROLE_SPLITTER)[0],
role -> new ArrayList<>(List.of(role.split(PROJECT_ROLE_SPLITTER)[1])), role -> new ArrayList<>(List.of(role.split(PROJECT_ROLE_SPLITTER)[1])),
......
...@@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTParser; import com.nimbusds.jwt.JWTParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
...@@ -17,7 +15,6 @@ import org.springframework.stereotype.Component; ...@@ -17,7 +15,6 @@ import org.springframework.stereotype.Component;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Component @Component
public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationToken> { public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationToken> {
...@@ -53,6 +50,7 @@ public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationTo ...@@ -53,6 +50,7 @@ public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationTo
if (role.contains("gitlab")) { if (role.contains("gitlab")) {
authorities.add(new SimpleGrantedAuthority("ROLE_" + role)); authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
} else { } else {
authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
authorities.add(new SimpleGrantedAuthority("ROLE_" + role.substring(role.lastIndexOf('_') + 1))); authorities.add(new SimpleGrantedAuthority("ROLE_" + role.substring(role.lastIndexOf('_') + 1)));
} }
} }
......
...@@ -33,7 +33,7 @@ public class DocumentJdbcRepository { ...@@ -33,7 +33,7 @@ public class DocumentJdbcRepository {
WHERE WHERE
DATE_TRUNC('day',created_at) >= :startDate DATE_TRUNC('day',created_at) >= :startDate
AND DATE_TRUNC('day',created_at) <= :endDate AND DATE_TRUNC('day',created_at) <= :endDate
--AND project in(:projects) AND project in(:projects)
GROUP BY GROUP BY
date date
ORDER BY ORDER BY
...@@ -61,11 +61,11 @@ public class DocumentJdbcRepository { ...@@ -61,11 +61,11 @@ public class DocumentJdbcRepository {
COUNT(1) as count COUNT(1) as count
FROM FROM
template_schema.document d template_schema.document d
inner join template_schema.template t on t.template_id = d.template_id inner join template_schema.template t on t.id = d.template_id
WHERE WHERE
DATE_TRUNC('day',created_at) >= :startDate DATE_TRUNC('day',created_at) >= :startDate
AND DATE_TRUNC('day',created_at) <= :endDate AND DATE_TRUNC('day',created_at) <= :endDate
--AND d.project in(:projects) AND d.project in(:projects)
GROUP BY GROUP BY
d.template_id, t.name d.template_id, t.name
ORDER BY ORDER BY
......
Markdown is supported
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