-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[full-ci] Webfinger redirect app (#8884)
- Loading branch information
Showing
14 changed files
with
4,476 additions
and
4,516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Webfinger redirect app | ||
|
||
We've added an app with the name `webfinger` which queries the oCIS webfinger service for the url of the oCIS instance of the user and performs a redirect. This app is not meant to be used in a standard deployment in its current state. It only uses web and its extension system as a platform. In the future this will become a multi tenancy select. | ||
|
||
https://github.com/owncloud/web/issues/8883 | ||
https://github.com/owncloud/web/pull/8884 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[main] | ||
host = https://www.transifex.com | ||
|
||
[o:owncloud-org:p:owncloud-web:r:webfinger] | ||
file_filter = locale/<lang>/LC_MESSAGES/app.po | ||
minimum_perc = 0 | ||
source_file = template.pot | ||
source_lang = en | ||
type = PO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "web-app-webfinger", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "ownCloud webfinger resolver", | ||
"license": "AGPL-3.0", | ||
"peerDependencies": { | ||
"design-system": "workspace:@ownclouders/design-system@*", | ||
"web-app-webfinger": "workspace:*", | ||
"web-client": "workspace:@ownclouders/web-client@*", | ||
"web-pkg": "workspace:@ownclouders/web-pkg@*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types' | ||
export * from './webfingerDiscovery' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface OwnCloudServer { | ||
rel: string | ||
href: string | ||
titles?: Record<string, string> | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/web-app-webfinger/src/discovery/webfingerDiscovery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { OwnCloudServer } from 'web-app-webfinger/src/discovery/types' | ||
import { ClientService } from 'web-pkg' | ||
import { urlJoin } from 'web-client/src/utils' | ||
|
||
interface OwnCloudInstancesResponse { | ||
subject: string | ||
links: OwnCloudServer[] | ||
} | ||
|
||
const OWNCLOUD_REL = 'http://webfinger.owncloud/rel/server-instance' | ||
|
||
export class WebfingerDiscovery { | ||
private serverUrl: string | ||
private clientService: ClientService | ||
|
||
constructor(serverUrl: string, clientService: ClientService) { | ||
this.serverUrl = serverUrl | ||
this.clientService = clientService | ||
} | ||
|
||
public async discoverOwnCloudServers(): Promise<OwnCloudServer[]> { | ||
const client = this.clientService.httpAuthenticated | ||
const url = | ||
urlJoin(this.serverUrl, '.well-known', 'webfinger') + `?resource=${encodeURI(this.serverUrl)}` | ||
const response: OwnCloudInstancesResponse = (await client.get(url)).data | ||
return response.links.filter((o) => o.rel === OWNCLOUD_REL) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import translations from '../l10n/translations.json' | ||
import Resolve from './views/Resolve.vue' | ||
|
||
// just a dummy function to trick gettext tools | ||
function $gettext(msg) { | ||
return msg | ||
} | ||
|
||
const appInfo = { | ||
name: $gettext('Webfinger'), | ||
id: 'webfinger', | ||
icon: 'fingerprint', | ||
isFileEditor: false | ||
} | ||
|
||
const routes = () => [ | ||
{ | ||
name: 'webfinger-root', | ||
path: '/', | ||
redirect: () => { | ||
return { name: 'webfinger-resolve' } | ||
} | ||
}, | ||
{ | ||
path: '/resolve', | ||
name: 'webfinger-resolve', | ||
component: Resolve, | ||
meta: { | ||
authContext: 'user', | ||
title: $gettext('Resolve destination'), | ||
entryPoint: true | ||
} | ||
} | ||
] | ||
|
||
export default { | ||
appInfo, | ||
routes, | ||
translations | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<main | ||
class="webfinger-resolve oc-height-viewport oc-flex oc-flex-column oc-flex-center oc-flex-middle" | ||
> | ||
<h1 class="oc-invisible-sr" v-text="pageTitle" /> | ||
<div class="oc-card oc-card-body oc-text-center oc-width-large"> | ||
<template v-if="hasError"> | ||
<h2 key="webfinger-resolve-error"> | ||
<span v-text="$gettext('Sorry!')" /> | ||
</h2> | ||
<p v-text="$gettext('Something went wrong.')" /> | ||
<p v-text="$gettext('We could not resolve the destination.')" /> | ||
</template> | ||
<template v-else> | ||
<h2 key="webfinger-resolve-loading"> | ||
<span v-text="$gettext('One moment please…')" /> | ||
</h2> | ||
<p v-text="$gettext('You are being redirected.')" /> | ||
</template> | ||
</div> | ||
</main> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, ref, unref, watch } from 'vue' | ||
import { useClientService, useConfigurationManager, useLoadingService, useRouteMeta } from 'web-pkg' | ||
import { OwnCloudServer, WebfingerDiscovery } from 'web-app-webfinger/src/discovery' | ||
import { useGettext } from 'vue3-gettext' | ||
export default defineComponent({ | ||
name: 'WebfingerResolve', | ||
setup() { | ||
const configurationManager = useConfigurationManager() | ||
const clientService = useClientService() | ||
const loadingService = useLoadingService() | ||
const { $gettext } = useGettext() | ||
const title = useRouteMeta('title', '') | ||
const pageTitle = computed(() => { | ||
return $gettext(unref(title)) | ||
}) | ||
const ownCloudServers = ref<OwnCloudServer[]>([]) | ||
const hasError = ref(false) | ||
const webfingerDiscovery = new WebfingerDiscovery(configurationManager.serverUrl, clientService) | ||
loadingService.addTask(async () => { | ||
try { | ||
const servers = await webfingerDiscovery.discoverOwnCloudServers() | ||
ownCloudServers.value = servers | ||
if (servers.length === 0) { | ||
hasError.value = true | ||
} | ||
} catch (e) { | ||
console.error(e) | ||
hasError.value = true | ||
} | ||
}) | ||
watch(ownCloudServers, (instances) => { | ||
if (instances.length === 0) { | ||
return | ||
} | ||
// we can't deal with multi-instance results. just pick the first one for now. | ||
window.location.href = ownCloudServers.value[0].href | ||
}) | ||
return { | ||
pageTitle, | ||
ownCloudInstances: ownCloudServers, | ||
hasError | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style lang="scss"> | ||
.webfinger-resolve { | ||
.oc-card { | ||
background: var(--oc-color-background-highlight); | ||
border-radius: 15px; | ||
&-body { | ||
h2 { | ||
margin-top: 0; | ||
} | ||
p { | ||
font-size: var(--oc-font-size-large); | ||
} | ||
} | ||
} | ||
} | ||
</style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.