Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
legacy-auth
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
Container registry
Model registry
Operate
Environments
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
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
middlewares
legacy-auth
Commits
5826bda2
Commit
5826bda2
authored
4 years ago
by
Sébastien DA ROCHA
Browse files
Options
Downloads
Patches
Plain Diff
OIDC versions of user add/del/renew resources
parent
eb718584
No related branches found
No related tags found
1 merge request
!17
Poc oidc
Pipeline
#8782
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/legacy/legacy.controller.ts
+20
-3
20 additions, 3 deletions
src/legacy/legacy.controller.ts
src/legacy/legacy.service.oidc.ts
+4
-27
4 additions, 27 deletions
src/legacy/legacy.service.oidc.ts
with
24 additions
and
30 deletions
src/legacy/legacy.controller.ts
+
20
−
3
View file @
5826bda2
...
@@ -265,7 +265,7 @@ export class LegacyController {
...
@@ -265,7 +265,7 @@ export class LegacyController {
const
token
:
JWTToken
=
req
.
headers
.
token
;
const
token
:
JWTToken
=
req
.
headers
.
token
;
try
{
try
{
let
userServices
;
let
userServices
;
if
(
token
.
authzKey
==
null
)
{
if
(
token
.
authzKey
==
null
)
{
// is OIDC token
userServices
=
await
this
.
legacyServiceOidc
.
getUserResources
(
token
.
email
);
userServices
=
await
this
.
legacyServiceOidc
.
getUserResources
(
token
.
email
);
}
else
{
}
else
{
userServices
=
await
this
.
legacyService
.
getUserResources
(
token
.
username
,
token
.
authzKey
);
userServices
=
await
this
.
legacyService
.
getUserResources
(
token
.
username
,
token
.
authzKey
);
...
@@ -307,6 +307,14 @@ export class LegacyController {
...
@@ -307,6 +307,14 @@ export class LegacyController {
@
Post
(
'
user/resources/renew
'
)
@
Post
(
'
user/resources/renew
'
)
@
ApiOperation
({
title
:
'
Renew access to a restricted access dataset for an existing user.
'
})
@
ApiOperation
({
title
:
'
Renew access to a restricted access dataset for an existing user.
'
})
@
ApiImplicitHeader
({
name
:
'
Cookie
'
,
description
:
'
The JWT token containing user information
'
,
})
@
ApiImplicitHeader
({
name
:
'
X-Xsrf-Token
'
,
description
:
'
Cross Site reference token contained in the JWT token
'
,
})
@
ApiImplicitHeader
({
@
ApiImplicitHeader
({
name
:
'
Cookie
'
,
name
:
'
Cookie
'
,
description
:
'
The JWT token is sent by the browser as a cookie (refer to the config of the Authentication project to know which key is used)
'
,
description
:
'
The JWT token is sent by the browser as a cookie (refer to the config of the Authentication project to know which key is used)
'
,
...
@@ -320,7 +328,11 @@ export class LegacyController {
...
@@ -320,7 +328,11 @@ export class LegacyController {
async
renewUserResource
(@
Req
()
req
,
@
Body
()
body
:
AccessRequest
[])
{
async
renewUserResource
(@
Req
()
req
,
@
Body
()
body
:
AccessRequest
[])
{
const
token
:
JWTToken
=
req
.
headers
.
token
;
const
token
:
JWTToken
=
req
.
headers
.
token
;
try
{
try
{
return
await
this
.
legacyService
.
renewUserResource
(
token
,
body
);
if
(
token
.
authzKey
==
null
)
{
// is OIDC token
return
await
this
.
legacyServiceOidc
.
renewUserResource
(
token
,
body
);
}
else
{
return
await
this
.
legacyService
.
renewUserResource
(
token
,
body
);
}
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
error
instanceof
HttpException
)
{
if
(
error
instanceof
HttpException
)
{
throw
error
;
throw
error
;
...
@@ -343,7 +355,12 @@ export class LegacyController {
...
@@ -343,7 +355,12 @@ export class LegacyController {
async
deleteUserResource
(@
Req
()
req
,
@
Body
()
body
)
{
async
deleteUserResource
(@
Req
()
req
,
@
Body
()
body
)
{
const
token
:
JWTToken
=
req
.
headers
.
token
;
const
token
:
JWTToken
=
req
.
headers
.
token
;
try
{
try
{
return
await
this
.
legacyService
.
deleteUserResource
(
token
,
body
);
if
(
token
.
authzKey
==
null
)
{
// is OIDC token
return
await
this
.
legacyServiceOidc
.
deleteUserResource
(
token
,
body
);
}
else
{
return
await
this
.
legacyService
.
deleteUserResource
(
token
,
body
);
}
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
error
instanceof
HttpException
)
{
if
(
error
instanceof
HttpException
)
{
throw
error
;
throw
error
;
...
...
This diff is collapsed.
Click to expand it.
src/legacy/legacy.service.oidc.ts
+
4
−
27
View file @
5826bda2
...
@@ -149,12 +149,6 @@ export class LegacyServiceOIDC extends LegacyService {
...
@@ -149,12 +149,6 @@ export class LegacyServiceOIDC extends LegacyService {
async
addUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessRequestResponse
>
{
async
addUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessRequestResponse
>
{
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
addUserResource
.
name
}
`
);
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
addUserResource
.
name
}
`
);
try
{
try
{
// Decrypt the password
const
password
=
decrypt
(
token
.
authzKey
,
await
this
.
configService
.
getPrivateKey
());
if
(
!
password
)
{
throw
new
UnauthorizedException
(
'
Invalid user credentials.
'
);
}
// Get the list of datasets
// Get the list of datasets
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
...
@@ -169,8 +163,7 @@ export class LegacyServiceOIDC extends LegacyService {
...
@@ -169,8 +163,7 @@ export class LegacyServiceOIDC extends LegacyService {
// Request access the the specified service and the specified modes
// Request access the the specified service and the specified modes
let
res
=
await
request
.
post
(
`
${
this
.
conf
.
legacyAuthServiceUrl
}
/add_user_service/`
).
form
(
let
res
=
await
request
.
post
(
`
${
this
.
conf
.
legacyAuthServiceUrl
}
/add_user_service/`
).
form
(
{
{
password
,
username
:
token
.
email
,
username
:
token
.
username
,
service_id
:
accessRequest
.
id
,
service_id
:
accessRequest
.
id
,
modes
:
accessRequest
.
servicesId
.
toString
(),
modes
:
accessRequest
.
servicesId
.
toString
(),
},
},
...
@@ -251,16 +244,8 @@ export class LegacyServiceOIDC extends LegacyService {
...
@@ -251,16 +244,8 @@ export class LegacyServiceOIDC extends LegacyService {
async
renewUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessRenewalResponse
>
{
async
renewUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessRenewalResponse
>
{
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
renewUserResource
.
name
}
`
);
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
renewUserResource
.
name
}
`
);
try
{
try
{
// Decrypt the password
const
password
=
decrypt
(
token
.
authzKey
,
await
this
.
configService
.
getPrivateKey
());
if
(
!
password
)
{
this
.
logger
.
warn
(
'
Invalid user credentials.
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
renewUserResource
.
name
}
`
);
throw
new
UnauthorizedException
(
'
Invalid user credentials.
'
);
}
// Get the list of user access
// Get the list of user access
const
userAccess
=
await
this
.
getUserResources
(
token
.
username
);
const
userAccess
=
await
this
.
getUserResources
(
token
.
email
);
// Get the list of datasets
// Get the list of datasets
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
// Get the list of services
// Get the list of services
...
@@ -354,13 +339,6 @@ export class LegacyServiceOIDC extends LegacyService {
...
@@ -354,13 +339,6 @@ export class LegacyServiceOIDC extends LegacyService {
async
deleteUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessDeletionResponse
>
{
async
deleteUserResource
(
token
:
JWTToken
,
accessRequests
:
AccessRequest
[]):
Promise
<
AccessDeletionResponse
>
{
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
deleteUserResource
.
name
}
`
);
this
.
logger
.
log
(
'
Entering function
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
deleteUserResource
.
name
}
`
);
try
{
try
{
// Decrypt the password
const
password
=
decrypt
(
token
.
authzKey
,
await
this
.
configService
.
getPrivateKey
());
if
(
!
password
)
{
this
.
logger
.
warn
(
'
Invalid user credentials.
'
,
`
${
LegacyServiceOIDC
.
name
}
-
${
this
.
deleteUserResource
.
name
}
`
);
throw
new
UnauthorizedException
(
'
Invalid user credentials.
'
);
}
// Get the list of datasets
// Get the list of datasets
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
const
datasets
=
await
this
.
getRestrictedAccessDatasets
();
...
@@ -373,10 +351,9 @@ export class LegacyServiceOIDC extends LegacyService {
...
@@ -373,10 +351,9 @@ export class LegacyServiceOIDC extends LegacyService {
for
(
const
accessRequest
of
accessRequests
)
{
for
(
const
accessRequest
of
accessRequests
)
{
// Delete access to the specified service and the specified modes
// Delete access to the specified service and the specified modes
let
res
=
await
request
.
post
(
`
${
this
.
conf
.
legacyAuthServiceUrl
}
/del_user_service/`
).
form
(
let
res
=
await
request
.
post
(
`
${
this
.
conf
.
legacyAuthServiceUrl
}
/del_user_service
_oidc
/`
).
form
(
{
{
password
,
username
:
token
.
email
,
username
:
token
.
username
,
service_id
:
accessRequest
.
id
,
service_id
:
accessRequest
.
id
,
modes
:
accessRequest
.
servicesId
.
toString
(),
modes
:
accessRequest
.
servicesId
.
toString
(),
},
},
...
...
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