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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aolda
proxy-manager-backend
Commits
b1ea5b7c
Commit
b1ea5b7c
authored
4 months ago
by
천 진강
Browse files
Options
Downloads
Patches
Plain Diff
feat: 토큰 발행시 프로젝트별 Role 반환
parent
e76498c5
Branches
Branches containing commit
No related tags found
3 merge requests
!15
Feat/certificate
,
!6
Feat/forwarding 포트포워딩 CRUD
,
!3
Feat/auth 프로젝트 role 조회 api 추가
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/aolda/itda/service/AuthService.java
+3
-31
3 additions, 31 deletions
src/main/java/com/aolda/itda/service/AuthService.java
with
3 additions
and
31 deletions
src/main/java/com/aolda/itda/service/AuthService.java
+
3
−
31
View file @
b1ea5b7c
...
@@ -2,7 +2,6 @@ package com.aolda.itda.service;
...
@@ -2,7 +2,6 @@ package com.aolda.itda.service;
import
com.aolda.itda.dto.auth.LoginRequestDTO
;
import
com.aolda.itda.dto.auth.LoginRequestDTO
;
import
com.aolda.itda.dto.auth.LoginResponseDTO
;
import
com.aolda.itda.dto.auth.LoginResponseDTO
;
import
com.aolda.itda.dto.auth.ProjectIdAndNameDTO
;
import
com.aolda.itda.dto.auth.ProjectRoleDTO
;
import
com.aolda.itda.dto.auth.ProjectRoleDTO
;
import
com.aolda.itda.exception.CustomException
;
import
com.aolda.itda.exception.CustomException
;
import
com.aolda.itda.exception.ErrorCode
;
import
com.aolda.itda.exception.ErrorCode
;
...
@@ -45,8 +44,7 @@ public class AuthService {
...
@@ -45,8 +44,7 @@ public class AuthService {
response
.
addHeader
(
"X-Subject-Token"
,
token
);
response
.
addHeader
(
"X-Subject-Token"
,
token
);
return
LoginResponseDTO
.
builder
()
return
LoginResponseDTO
.
builder
()
.
isAdmin
(
false
)
.
lists
(
getRolesWithProjects
(
user
))
.
lists
(
getProjectsWithUser
(
user
))
.
build
();
.
build
();
}
}
...
@@ -65,9 +63,11 @@ public class AuthService {
...
@@ -65,9 +63,11 @@ public class AuthService {
" ],\n"
+
" ],\n"
+
" \"password\": {\n"
+
" \"password\": {\n"
+
" \"user\": {\n"
+
" \"user\": {\n"
+
" \"name\": \""
+
id
+
"\",\n"
+
" \"domain\": {\n"
+
" \"domain\": {\n"
+
" \"name\": \"Default\"\n"
+
" \"name\": \"Default\"\n"
+
" },\n"
+
" },\n"
+
" \"password\": \""
+
password
+
"\"\n"
+
" }\n"
+
" }\n"
+
" }\n"
+
" }\n"
+
" }\n"
+
" }\n"
+
...
@@ -126,32 +126,4 @@ public class AuthService {
...
@@ -126,32 +126,4 @@ public class AuthService {
Map
<
String
,
String
>
user
=
getToken
(
adminId
,
adminPassword
);
Map
<
String
,
String
>
user
=
getToken
(
adminId
,
adminPassword
);
return
user
.
get
(
"token"
);
return
user
.
get
(
"token"
);
}
}
private
List
<
ProjectIdAndNameDTO
>
getProjectsWithUser
(
Map
<
String
,
String
>
user
)
throws
JsonProcessingException
{
String
userId
=
user
.
get
(
"id"
);
String
token
=
user
.
get
(
"token"
);
if
(
userId
==
null
||
token
==
null
)
{
throw
new
CustomException
(
ErrorCode
.
INVALID_USER_INFO
);
}
String
url
=
keystone
+
"/users/"
+
userId
+
"/projects"
;
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"X-Auth-Token"
,
getAdminToken
());
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
headers
);
ResponseEntity
<
String
>
res
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
JsonNode
node
=
objectMapper
.
readTree
(
res
.
getBody
());
ArrayNode
arrayNode
=
(
ArrayNode
)
node
.
get
(
"projects"
);
List
<
ProjectIdAndNameDTO
>
lists
=
new
ArrayList
<>();
for
(
JsonNode
assignment
:
arrayNode
)
{
String
projectId
=
assignment
.
path
(
"id"
).
asText
();
String
projectName
=
assignment
.
path
(
"name"
).
asText
();
lists
.
add
(
new
ProjectIdAndNameDTO
(
projectId
,
projectName
));
}
return
lists
;
}
}
}
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