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
f78e1cd5
Commit
f78e1cd5
authored
Jan 24, 2024
by
Denis
Committed by
Denis Ligin
Jan 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Security issue fix
parent
6c420f34
Pipeline
#372
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
src/main/java/kz/project/printedFormsService/config/SecurityConfiguration.java
...ect/printedFormsService/config/SecurityConfiguration.java
+9
-4
src/main/java/kz/project/printedFormsService/service/impl/GitlabClientImpl.java
...ct/printedFormsService/service/impl/GitlabClientImpl.java
+5
-4
No files found.
src/main/java/kz/project/printedFormsService/config/SecurityConfiguration.java
View file @
f78e1cd5
...
@@ -47,6 +47,7 @@ public class SecurityConfiguration {
...
@@ -47,6 +47,7 @@ public class SecurityConfiguration {
http
.
sessionManagement
(
sm
->
sm
.
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
));
http
.
sessionManagement
(
sm
->
sm
.
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
));
http
.
csrf
(
AbstractHttpConfigurer:
:
disable
);
http
.
csrf
(
AbstractHttpConfigurer:
:
disable
);
http
.
anonymous
(
AbstractHttpConfigurer:
:
disable
);
http
.
exceptionHandling
(
eh
->
eh
.
authenticationEntryPoint
((
request
,
response
,
authException
)
->
{
http
.
exceptionHandling
(
eh
->
eh
.
authenticationEntryPoint
((
request
,
response
,
authException
)
->
{
response
.
addHeader
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Bearer realm=\"Restricted Content\""
);
response
.
addHeader
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Bearer realm=\"Restricted Content\""
);
...
@@ -57,9 +58,7 @@ public class SecurityConfiguration {
...
@@ -57,9 +58,7 @@ public class SecurityConfiguration {
.
requestMatchers
(
"/actuator/health/readiness"
,
.
requestMatchers
(
"/actuator/health/readiness"
,
"/actuator/health/liveness"
,
"/actuator/health/liveness"
,
"/api-docs/**"
,
"/api-docs/**"
,
"/swagger-ui/**"
,
"/swagger-ui/**"
BASE_PATH
+
TemplateController
.
GET_TEMPLATE
,
DTemplateTypeController
.
BASE_PATH
+
DTemplateTypeController
.
GET_ALL
)
)
.
permitAll
()
.
permitAll
()
...
@@ -93,7 +92,13 @@ public class SecurityConfiguration {
...
@@ -93,7 +92,13 @@ public class SecurityConfiguration {
.
requestMatchers
(
GitlabTemplateController
.
EDIT
)
.
requestMatchers
(
GitlabTemplateController
.
EDIT
)
.
hasAnyRole
(
EDITOR
,
ADMIN
)
.
hasAnyRole
(
EDITOR
,
ADMIN
)
.
anyRequest
().
authenticated
()
.
requestMatchers
(
BASE_PATH
+
TemplateController
.
GET_TEMPLATE
,
DTemplateTypeController
.
BASE_PATH
+
DTemplateTypeController
.
GET_ALL
)
.
permitAll
()
.
anyRequest
().
fullyAuthenticated
()
);
);
...
...
src/main/java/kz/project/printedFormsService/service/impl/GitlabClientImpl.java
View file @
f78e1cd5
...
@@ -2,6 +2,7 @@ package kz.project.printedFormsService.service.impl;
...
@@ -2,6 +2,7 @@ package kz.project.printedFormsService.service.impl;
import
kz.project.printedFormsService.data.dto.GitlabMultipartFile
;
import
kz.project.printedFormsService.data.dto.GitlabMultipartFile
;
import
kz.project.printedFormsService.service.GitlabClient
;
import
kz.project.printedFormsService.service.GitlabClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -11,6 +12,7 @@ import reactor.core.publisher.Mono;
...
@@ -11,6 +12,7 @@ import reactor.core.publisher.Mono;
import
java.io.File
;
import
java.io.File
;
@Service
@Service
@Slf4j
public
class
GitlabClientImpl
implements
GitlabClient
{
public
class
GitlabClientImpl
implements
GitlabClient
{
private
final
WebClient
webClient
;
private
final
WebClient
webClient
;
...
@@ -22,7 +24,6 @@ public class GitlabClientImpl implements GitlabClient {
...
@@ -22,7 +24,6 @@ public class GitlabClientImpl implements GitlabClient {
.
build
();
.
build
();
}
}
//http://gitlab.lan.arta.kz/d.ermakov/templates/-/raw/master/dto.txt?inline=false
@Override
@Override
public
Mono
<
byte
[]>
downloadFileFromGitLab
(
String
projectName
,
String
filePath
,
String
branch
)
{
public
Mono
<
byte
[]>
downloadFileFromGitLab
(
String
projectName
,
String
filePath
,
String
branch
)
{
String
urlPath
=
String
.
format
(
"/api/v4/projects/%s/repository/files/%s/raw"
,
projectName
,
filePath
);
String
urlPath
=
String
.
format
(
"/api/v4/projects/%s/repository/files/%s/raw"
,
projectName
,
filePath
);
...
@@ -33,7 +34,7 @@ public class GitlabClientImpl implements GitlabClient {
...
@@ -33,7 +34,7 @@ public class GitlabClientImpl implements GitlabClient {
.
build
())
.
build
())
.
retrieve
()
.
retrieve
()
.
bodyToMono
(
byte
[].
class
)
.
bodyToMono
(
byte
[].
class
)
.
doOnError
(
error
->
System
.
err
.
println
(
"Error downloading file: "
+
error
.
getMessage
()));
.
doOnError
(
error
->
log
.
error
(
"Error downloading file: {}"
,
error
.
getMessage
()));
}
}
@Override
@Override
...
@@ -46,7 +47,7 @@ public class GitlabClientImpl implements GitlabClient {
...
@@ -46,7 +47,7 @@ public class GitlabClientImpl implements GitlabClient {
.
build
())
.
build
())
.
retrieve
()
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
bodyToMono
(
String
.
class
)
.
doOnError
(
error
->
System
.
err
.
println
(
"Error downloading file: "
+
error
.
getMessage
()));
.
doOnError
(
error
->
log
.
error
(
"Error downloading file: {}"
,
error
.
getMessage
()));
}
}
@Override
@Override
...
@@ -63,7 +64,7 @@ public class GitlabClientImpl implements GitlabClient {
...
@@ -63,7 +64,7 @@ public class GitlabClientImpl implements GitlabClient {
File
file
=
new
File
(
filePath
);
File
file
=
new
File
(
filePath
);
return
new
GitlabMultipartFile
(
file
.
getName
(),
file
.
getName
(),
null
,
bytes
);
return
new
GitlabMultipartFile
(
file
.
getName
(),
file
.
getName
(),
null
,
bytes
);
})
})
.
doOnError
(
error
->
System
.
err
.
println
(
"Error downloading file: "
+
error
.
getMessage
()))
.
doOnError
(
error
->
log
.
error
(
"Error downloading file: {}"
,
error
.
getMessage
()))
.
block
();
.
block
();
}
}
}
}
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