Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
templateService
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bazarbay Tulenov
templateService
Commits
66a9e279
Commit
66a9e279
authored
Dec 25, 2023
by
Denis
Committed by
Denis Ligin
Dec 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
403 fix
parent
73ff187e
Pipeline
#331
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
29 deletions
+16
-29
src/main/java/kz/project/printedFormsService/config/SecurityConfiguration.java
...ect/printedFormsService/config/SecurityConfiguration.java
+11
-21
src/main/java/kz/project/printedFormsService/converter/JwtAuthConverter.java
...oject/printedFormsService/converter/JwtAuthConverter.java
+3
-6
src/main/java/kz/project/printedFormsService/data/repository/DocumentJdbcRepository.java
...dFormsService/data/repository/DocumentJdbcRepository.java
+2
-2
No files found.
src/main/java/kz/project/printedFormsService/config/SecurityConfiguration.java
View file @
66a9e279
...
...
@@ -30,12 +30,9 @@ import static kz.project.printedFormsService.controller.TemplateController.BASE_
@EnableMethodSecurity
public
class
SecurityConfiguration
{
private
static
final
String
PROJECT_A_CREATOR
=
"projecta_creator"
;
private
static
final
String
PROJECT_B_CREATOR
=
"projectb_creator"
;
private
static
final
String
PROJECT_A_DELETE
=
"projecta_delete"
;
private
static
final
String
PROJECT_B_DELETE
=
"projectb_delete"
;
private
static
final
String
PROJECT_A_EDITOR
=
"projecta_editor"
;
private
static
final
String
PROJECT_B_EDITOR
=
"projectb_editor"
;
private
static
final
String
CREATOR
=
"creator"
;
private
static
final
String
DELETE
=
"delete"
;
private
static
final
String
EDITOR
=
"editor"
;
private
static
final
String
ADMIN
=
"admin"
;
@Bean
...
...
@@ -66,36 +63,29 @@ public class SecurityConfiguration {
.
permitAll
()
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
SAVE
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_
CREATOR
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
GET_TEMPLATE_DATA
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_CREATOR
,
PROJECT_A_EDITOR
,
PROJECT_B_EDITOR
,
PROJECT_A_DELETE
,
PROJECT_B_DELETE
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
EDITOR
,
DELETE
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
EDIT
)
.
hasAnyRole
(
PROJECT_A_EDITOR
,
PROJECT_B_
EDITOR
,
ADMIN
)
.
hasAnyRole
(
EDITOR
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
DELETE
)
.
hasAnyRole
(
PROJECT_A_DELETE
,
PROJECT_B_
DELETE
,
ADMIN
)
.
hasAnyRole
(
DELETE
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
GET_ALL
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_CREATOR
,
PROJECT_A_EDITOR
,
PROJECT_B_EDITOR
,
PROJECT_A_DELETE
,
PROJECT_B_DELETE
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
EDITOR
,
DELETE
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
GET_ALL_BY_CODE
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_CREATOR
,
PROJECT_A_EDITOR
,
PROJECT_B_EDITOR
,
PROJECT_A_DELETE
,
PROJECT_B_DELETE
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
EDITOR
,
DELETE
,
ADMIN
)
.
requestMatchers
(
DocumentsController
.
BY_DAY
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_CREATOR
,
PROJECT_A_EDITOR
,
PROJECT_B_EDITOR
,
PROJECT_A_DELETE
,
PROJECT_B_DELETE
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
EDITOR
,
DELETE
,
ADMIN
)
.
requestMatchers
(
DocumentsController
.
BY_TEMPLATE
)
.
hasAnyRole
(
PROJECT_A_CREATOR
,
PROJECT_B_CREATOR
,
PROJECT_A_EDITOR
,
PROJECT_B_EDITOR
,
PROJECT_A_DELETE
,
PROJECT_B_DELETE
,
ADMIN
)
.
hasAnyRole
(
CREATOR
,
EDITOR
,
DELETE
,
ADMIN
)
.
requestMatchers
(
BASE_PATH
+
"/**"
)
.
hasAnyRole
(
ADMIN
)
.
anyRequest
().
authenticated
()
);
...
...
src/main/java/kz/project/printedFormsService/converter/JwtAuthConverter.java
View file @
66a9e279
...
...
@@ -11,10 +11,7 @@ import org.springframework.security.oauth2.jwt.Jwt;
import
org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Component
public
class
JwtAuthConverter
implements
Converter
<
Jwt
,
AbstractAuthenticationToken
>
{
...
...
@@ -34,10 +31,10 @@ public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationTo
ObjectMapper
mapper
=
new
ObjectMapper
();
List
<
String
>
roles
=
mapper
.
convertValue
(
resourceAccess
.
get
(
"print_form"
).
get
(
"roles"
),
new
TypeReference
<>()
{
});
List
<
GrantedAuthority
>
authorities
=
new
ArrayLis
t
<>();
Set
<
GrantedAuthority
>
authorities
=
new
HashSe
t
<>();
for
(
String
role
:
roles
)
{
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_"
+
role
));
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_"
+
role
.
substring
(
role
.
lastIndexOf
(
'_'
)+
1
)
));
}
return
authorities
;
...
...
src/main/java/kz/project/printedFormsService/data/repository/DocumentJdbcRepository.java
View file @
66a9e279
...
...
@@ -33,7 +33,7 @@ public class DocumentJdbcRepository {
WHERE
DATE_TRUNC('day',created_at) >= :startDate
AND DATE_TRUNC('day',created_at) <= :endDate
AND project in(:projects)
--
AND project in(:projects)
GROUP BY
date
ORDER BY
...
...
@@ -65,7 +65,7 @@ public class DocumentJdbcRepository {
WHERE
DATE_TRUNC('day',created_at) >= :startDate
AND DATE_TRUNC('day',created_at) <= :endDate
AND d.project in(:projects)
--
AND d.project in(:projects)
GROUP BY
d.template_id, t.name
ORDER BY
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment