Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
04445971
Commit
04445971
authored
3 years ago
by
Steinwender, Tamara
Browse files
Options
Downloads
Patches
Plain Diff
Repair the decryption functionality in nextcloudfilepickeer and decrypt the session if logged in
parent
02643743
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/file-handling/src/crypto.js
+4
-8
4 additions, 8 deletions
packages/file-handling/src/crypto.js
packages/file-handling/src/nextcloud-file-picker.js
+27
-18
27 additions, 18 deletions
packages/file-handling/src/nextcloud-file-picker.js
with
31 additions
and
26 deletions
packages/file-handling/src/crypto.js
+
4
−
8
View file @
04445971
import
{
CompactEncrypt
}
from
'
jose/jwe/compact/encrypt
'
;
import
{
compactDecrypt
}
from
'
jose/jwe/compact/decrypt
'
;
import
{
parseJwk
}
from
'
jose/jwk/parse
'
;
import
{
encode
}
from
'
jose/util/base64url
'
;
...
...
@@ -26,7 +27,6 @@ export async function encrypt(token, payload) {
const
jwe
=
await
new
CompactEncrypt
(
encoder
.
encode
(
payload
))
.
setProtectedHeader
({
alg
:
'
PBES2-HS256+A128KW
'
,
enc
:
'
A256GCM
'
})
.
encrypt
(
key
);
console
.
log
(
"
+++++++++++
"
,
jwe
);
return
jwe
;
}
...
...
@@ -50,15 +50,11 @@ export async function encrypt(token, payload) {
* @returns {string}
*/
export
async
function
decrypt
(
token
,
payload
)
{
console
.
log
(
"
payload
"
,
payload
);
const
encoder
=
new
TextEncoder
();
const
key
=
await
parseJwk
({
kty
:
'
oct
'
,
k
:
encode
(
token
)},
'
PBES2-HS256+A128KW
'
);
const
jwe
=
await
new
CompactEncrypt
(
encoder
.
encode
(
payload
))
.
setProtectedHeader
({
alg
:
'
PBES2-HS256+A128KW
'
,
enc
:
'
A256GCM
'
})
.
decrypt
(
key
);
console
.
log
(
"
jwe
"
,
jwe
);
const
decryption
=
await
compactDecrypt
(
payload
,
key
,
{
alg
:
'
PBES2-HS256+A128KW
'
,
enc
:
'
A256GCM
'
});
const
secret
=
new
TextDecoder
().
decode
(
decryption
.
plaintext
);
return
jwe
;
return
secret
;
}
export
function
parseJwt
(
token
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/file-handling/src/nextcloud-file-picker.js
+
27
−
18
View file @
04445971
...
...
@@ -422,24 +422,32 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
*
*/
async
checkSessionStorage
()
{
if
(
!
this
.
isLoggedIn
()
||
!
this
.
auth
)
return
;
const
publicId
=
this
.
auth
[
'
person-id
'
];
const
token
=
parseJwt
(
this
.
auth
.
token
);
const
sessionId
=
token
?
token
.
sid
:
""
;
if
(
this
.
isLoggedIn
()
&&
this
.
storeSession
&&
sessionId
if
(
this
.
storeSession
&&
sessionId
&&
sessionStorage
.
getItem
(
"
nextcloud-webdav-username
"
+
publicId
)
&&
sessionStorage
.
getItem
(
"
nextcloud-webdav-password
"
+
publicId
)
){
console
.
log
(
"
----------
"
,
sessionStorage
.
getItem
(
"
nextcloud-webdav-username
"
+
publicId
));
const
se
ssionStorageName
=
await
sessionStorage
.
getItem
(
"
nextcloud-webdav-username
"
+
publicId
);
console
.
log
(
"
decrypt:
"
,
await
decrypt
(
sessionId
,
sessionStorage
Name
));
/*
this.webDavClient = createClient(
this.webDavUrl + "/" +
sessionStorage.getItem("nextcloud-webdav-
user
n
ame
")
,
try
{
const
u
se
rName
=
await
decrypt
(
sessionId
,
sessionStorage
.
getItem
(
"
nextcloud-webdav-username
"
+
publicId
)
)
;
const
password
=
await
decrypt
(
sessionId
,
sessionStorage
.
getItem
(
"
nextcloud-webdav-password
"
+
publicId
));
this
.
webDavClient
=
createClient
(
this
.
webDavUrl
+
"
/
"
+
user
N
ame
,
{
username:
decrypt(sessionId, sessionStorage.getItem("nextcloud-webdav-
user
n
ame
" + publicId))
,
password:
decrypt(sessionId, sessionStorage.getItem("nextcloud-webdav-password" + publicId))
username
:
user
N
ame
,
password
:
password
}
);
this
.
isPickerActive
=
true
;
this.loadDirectory(this.directoryPath);*/
this
.
loadDirectory
(
this
.
directoryPath
);
}
catch
(
e
)
{
sessionStorage
.
removeItem
(
'
nextcloud-webdav-username
'
+
publicId
);
sessionStorage
.
removeItem
(
'
nextcloud-webdav-password
'
+
publicId
);
return
;
}
}
}
...
...
@@ -1225,10 +1233,11 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
logOut
()
{
this
.
webDavClient
=
null
;
this
.
isPickerActive
=
false
;
sessionStorage
.
removeItem
(
'
nextcloud-webdav-username
'
);
sessionStorage
.
removeItem
(
'
nextcloud-webdav-password
'
);
console
.
log
(
"
log out!
"
);
if
(
this
.
auth
)
{
const
publicId
=
this
.
auth
[
'
person-id
'
];
sessionStorage
.
removeItem
(
'
nextcloud-webdav-username
'
+
publicId
);
sessionStorage
.
removeItem
(
'
nextcloud-webdav-password
'
+
publicId
);
}
}
/**
...
...
@@ -1815,7 +1824,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
}}
">
${
i18n
.
t
(
'
nextcloud-file-picker.connect-nextcloud
'
,
{
name
:
this
.
nextcloudName
})}
</button>
</div>
<div class="block text-center m-inherit
${
classMap
({
hidden
:
this
.
isPickerActive
&&
!
this
.
storeSession
})}
"> <!-- remove hidden to enable remember me -->
<div class="block text-center m-inherit
${
classMap
({
hidden
:
this
.
isPickerActive
&&
!
this
.
storeSession
||
!
this
.
isLoggedIn
()
})}
"> <!-- remove hidden to enable remember me -->
<label class="button-container remember-container">
${
i18n
.
t
(
'
nextcloud-file-picker.remember-me
'
)}
<input type="checkbox" id="remember-checkbox" name="remember">
...
...
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