Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
proxy-manager-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aolda
proxy-manager-backend
Commits
017ea5c5
Commit
017ea5c5
authored
2 months ago
by
천 진강
Browse files
Options
Downloads
Patches
Plain Diff
fix: 프로젝트 역할과 권한이 일치하지 않던 문제 해결
parent
1b407531
No related branches found
No related tags found
2 merge requests
!15
Feat/certificate
,
!14
Feat/main 자잘한 변경 사항들
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/aolda/itda/config/AuthInterceptor.java
+3
-3
3 additions, 3 deletions
src/main/java/com/aolda/itda/config/AuthInterceptor.java
src/main/java/com/aolda/itda/service/AuthService.java
+5
-8
5 additions, 8 deletions
src/main/java/com/aolda/itda/service/AuthService.java
with
8 additions
and
11 deletions
src/main/java/com/aolda/itda/config/AuthInterceptor.java
+
3
−
3
View file @
017ea5c5
...
...
@@ -43,10 +43,10 @@ public class AuthInterceptor implements HandlerInterceptor {
if
(
projectId
!=
null
)
{
try
{
String
role
=
authService
.
getBestRoleWithinProject
(
token
,
projectId
).
get
(
"role"
);
if
(!
role
.
equals
(
"admin"
))
{
log
.
error
(
"Unauthorized Token for URI {}: {}"
,
request
.
getRequestURI
(),
request
.
getRemoteAddr
());
authService
.
getBestRoleWithinProject
(
token
,
projectId
).
get
(
"role"
);
if
(!
request
.
getMethod
().
equals
(
"GET"
)
&&
!
authService
.
getBestRoleWithinProject
(
token
,
projectId
).
get
(
"role"
).
equals
(
"admin"
))
{
throw
new
CustomException
(
ErrorCode
.
UNAUTHORIZED_USER
,
request
.
getRequestURI
());
}
}
catch
(
Exception
e
)
{
throw
new
CustomException
(
ErrorCode
.
UNAUTHORIZED_USER
,
request
.
getRequestURI
());
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/aolda/itda/service/AuthService.java
+
5
−
8
View file @
017ea5c5
...
...
@@ -96,7 +96,6 @@ public class AuthService {
try
{
res
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
Map
.
class
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
CustomException
(
ErrorCode
.
INVALID_USER_INFO
);
}
Map
<
String
,
Object
>
resToken
=
(
Map
<
String
,
Object
>)
res
.
getBody
().
get
(
"token"
);
...
...
@@ -140,7 +139,7 @@ public class AuthService {
try
{
requestEntity
=
new
HttpEntity
<>(
requestBody
,
headers
);
res
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
Map
.
class
);
}
catch
(
Runtime
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
null
;
}
...
...
@@ -185,8 +184,7 @@ public class AuthService {
}
catch
(
HttpClientErrorException
.
Forbidden
e
)
{
return
unscopedToken
;
}
catch
(
RuntimeException
e
)
{
e
.
printStackTrace
();
catch
(
Exception
e
)
{
throw
new
CustomException
(
ErrorCode
.
INVALID_TOKEN
);
}
...
...
@@ -290,7 +288,7 @@ public class AuthService {
ResponseEntity
<
String
>
res
;
try
{
res
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
}
catch
(
HttpClientErrorException
.
NotFound
e
)
{
}
catch
(
Exception
e
)
{
throw
new
CustomException
(
ErrorCode
.
INVALID_TOKEN
);
}
return
objectMapper
.
readTree
(
res
.
getBody
()).
path
(
"token"
).
path
(
"user"
).
path
(
"id"
).
asText
();
...
...
@@ -305,7 +303,7 @@ public class AuthService {
ResponseEntity
<
String
>
res
;
try
{
res
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
}
catch
(
HttpClientErrorException
.
NotFound
e
)
{
}
catch
(
Exception
e
)
{
throw
new
CustomException
(
ErrorCode
.
INVALID_TOKEN
);
}
...
...
@@ -338,8 +336,7 @@ public class AuthService {
ResponseEntity
<
String
>
res
;
try
{
res
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
}
catch
(
RuntimeException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
return
false
;
}
JsonNode
node
=
objectMapper
.
readTree
(
res
.
getBody
()).
path
(
"role_assignments"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment