Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files_external): basic auth user storage trigger #40782

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/files_external/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function getUserMounts(): DataResponse {

/**
* @NoAdminRequired
* @NoCSRFRequired
artonge marked this conversation as resolved.
Show resolved Hide resolved
*
* Ask for credentials using a browser's native basic auth prompt
* Then returns it if provided
Expand Down
8 changes: 5 additions & 3 deletions apps/files_external/src/actions/enterCredentialsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export const action = new FileAction({

async exec(node: Node) {
// always resolve auth request, we'll process the data afterwards
const response = await axios.get(generateOcsUrl('/apps/files_external/api/v1/auth'), {
validateStatus: () => true,
// Using fetch as axios have integrated auth handling and X-Requested-With header
const response = await fetch(generateOcsUrl('/apps/files_external/api/v1/auth'), {
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
headers: new Headers({ Accept: 'application/json' }),
credentials: 'include',
})

const data = (response?.data || {}) as OCSAuthResponse
const data = (await response?.json() || {}) as OCSAuthResponse
if (data.ocs.data.user && data.ocs.data.password) {
const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', node.attributes), {
backendOptions: data.ocs.data,
Expand Down
4 changes: 2 additions & 2 deletions dist/files_external-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_external-init.js.map

Large diffs are not rendered by default.

Loading