Skip to content
Open
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
19 changes: 18 additions & 1 deletion packages/web-pkg/src/components/CreateLinkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
isFolder
})
"
>{{ $gettext('Copy link and password') }}
>{{ confirmPasswordButtonText }}
</oc-button>
</li>
</oc-list>
Expand Down Expand Up @@ -193,6 +193,13 @@ export default defineComponent({
return $gettext('Copy link')
})

const confirmPasswordButtonText = computed(() => {
if (unref(isEmbedEnabled)) {
return $gettext('Share link(s) and password(s)')
}
return $gettext('Copy link and password')
})

const passwordInputKey = ref(uuidV4())
const roleRefs = ref<Record<string, RoleRef>>({})

Expand Down Expand Up @@ -265,12 +272,21 @@ export default defineComponent({
const result = await createLinks()

const succeeded = result.filter(({ status }) => status === 'fulfilled')
// **DEPRECATED**: Always emit the share url for backwards compatibility
if (succeeded.length && unref(isEmbedEnabled)) {
postMessage<string[]>(
'owncloud-embed:share',
(succeeded as PromiseFulfilledResult<LinkShare>[]).map(({ value }) => value.webUrl)
)
}
// Always emit new event with objects, include password only when copyPassword is enabled
postMessage<Array<{ url: string; password?: string }>>(
'owncloud-embed:share-links',
(succeeded as PromiseFulfilledResult<LinkShare>[]).map(({ value }) => ({
url: value.webUrl,
...(options.copyPassword && { password: password.value })
}))
)

const userFacingErrors: Error[] = []
const failed = result.filter(({ status }) => status === 'rejected')
Expand Down Expand Up @@ -350,6 +366,7 @@ export default defineComponent({
updatePassword,
getLinkRoleByType,
confirmButtonText,
confirmPasswordButtonText,
isAdvancedMode,
setAdvancedMode,
onExpiryDateChanged,
Expand Down
4 changes: 3 additions & 1 deletion packages/web-pkg/src/composables/embedMode/useEmbedMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export const useEmbedMode = () => {
return configStore.options.embed?.fileTypes
})

const messagesTargetOrigin = computed(() => configStore.options.embed?.messagesOrigin)
const messagesTargetOrigin = computed(() => {
return configStore.options.embed?.messagesOrigin
})

const isDelegatingAuthentication = computed(
() => unref(isEnabled) && configStore.options.embed?.delegateAuthentication
Expand Down
6 changes: 6 additions & 0 deletions packages/web-runtime/src/container/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ const getEmbedConfigFromQuery = (
config.delegateAuthenticationOrigin = delegateAuthenticationOrigin
}

const messagesOrigin = getQueryParam('embed-messages-origin')

if (messagesOrigin) {
config.messagesOrigin = messagesOrigin
}

return config
}

Expand Down
2 changes: 2 additions & 0 deletions packages/web-runtime/src/pages/oidcCallback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export default defineComponent({

if (unref(route).path === '/web-oidc-silent-redirect') {
authService.signInSilentCallback()
} else if (unref(route).path === '/web-oidc-popup-callback') {
authService.signInPopupCallback()
} else {
authService.signInCallback()
}
Expand Down
6 changes: 6 additions & 0 deletions packages/web-runtime/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const routes = [
component: OidcCallbackPage,
meta: { title: $gettext('Oidc redirect'), authContext: 'anonymous' }
},
{
path: '/web-oidc-popup-callback',
name: 'oidcPopupCallback',
component: OidcCallbackPage,
meta: { title: $gettext('Oidc popup callback'), authContext: 'anonymous' }
},
{
path: '/f/:fileId',
name: 'resolvePrivateLink',
Expand Down
16 changes: 14 additions & 2 deletions packages/web-runtime/src/services/auth/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
CapabilityStore,
ConfigStore,
useTokenTimerWorker,
AuthServiceInterface
AuthServiceInterface,
useEmbedMode
} from '@ownclouders/web-pkg'
import { RouteLocation, Router } from 'vue-router'
import {
Expand All @@ -18,7 +19,7 @@ import {
isUserContextRequired
} from '../../router'
import { unref } from 'vue'
import { Ability } from '@ownclouders/web-client'
import { Ability, urlJoin } from '@ownclouders/web-client'
import { Language } from 'vue3-gettext'
import { PublicLinkType } from '@ownclouders/web-client'
import { WebWorkersStore } from '@ownclouders/web-pkg'
Expand Down Expand Up @@ -235,6 +236,13 @@ export class AuthService implements AuthServiceInterface {
}

public loginUser(redirectUrl?: string) {
const { isEnabled: isEmbedModeEnable } = useEmbedMode()
// if embed mode is enabled, use popup login instead of a redirect
if (unref(isEmbedModeEnable)) {
return this.userManager.signinPopup({
redirect_uri: urlJoin(unref(this.configStore.serverUrl), 'web-oidc-popup-callback')
})
}
this.userManager.setPostLoginRedirectUrl(redirectUrl)
return this.userManager.signinRedirect()
}
Expand Down Expand Up @@ -285,6 +293,10 @@ export class AuthService implements AuthServiceInterface {
await this.userManager.signinSilentCallback(this.buildSignInCallbackUrl())
}

public async signInPopupCallback() {
await this.userManager.signinPopupCallback(this.buildSignInCallbackUrl())
}

/**
* craft a url that the parser in oidc-client-ts can handle…
*/
Expand Down