Skip to content
Closed
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
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ More information is available in the External sites documentation.]]></descripti
<bugs>https://github.com/nextcloud/external/issues</bugs>
<repository type="git">https://github.com/nextcloud/external.git</repository>

<version>3.4.0</version>
<version>3.5.0</version>
<namespace>External</namespace>

<dependencies>
<nextcloud min-version="17" max-version="17" />
<nextcloud min-version="18" max-version="18" />
</dependencies>

<settings>
Expand Down
15 changes: 14 additions & 1 deletion js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
});

Handlebars.registerHelper('getTypes', function() {
return OCA.External.App.availableTypes;
return OCA.External.App.availableTypes;z
});

Handlebars.registerHelper('getDevices', function() {
Expand All @@ -60,6 +60,10 @@
defaults: {
name: '',
url: '',
loginurl: '',
login: '',
password: '',
headers: '',
lang: '',
type: 'link',
device: '',
Expand Down Expand Up @@ -96,6 +100,11 @@
_renderSite: function(data) {
data.nameTXT = t('external', 'Name');
data.urlTXT = t('external', 'URL');
data.authTXT = t('external', 'Auth');
data.loginUrlTXT = t('external', 'LoginUrl');
data.loginTXT = t('external', 'Login');
data.passwordTXT = t('external', 'Password');
data.headersTXT = t('external', 'Headers');
data.languageTXT = t('external', 'Language');
data.groupsTXT = t('external', 'Groups');
data.devicesTXT = t('external', 'Devices');
Expand Down Expand Up @@ -225,6 +234,10 @@
data = {
name: $site.find('.site-name').val(),
url: $site.find('.site-url').val(),
loginurl: $site.find('.site-loginurl').val(),
login: $site.find('.site-login').val(),
password: $site.find('.site-password').val(),
headers: $site.find('.site-headers').val(),
lang: $site.find('.site-lang').val(),
type: $site.find('.site-type').val(),
device: $site.find('.site-device').val(),
Expand Down
30 changes: 30 additions & 0 deletions js/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,34 @@ $(document).ready(function () {

document.getElementById('ifm').onload = resizeIframe;
window.onresize = resizeIframe;

var credentials = {
"username": $("#external_username").val(),
"password": $("#external_password").val(),
};

$.ajax({
url: $("#external_loginurl").val(),
type: "POST",
dataType: 'json',
/*
contentType: 'application/json',
data: JSON.stringify(credentials),
processData: false,
*/
data: credentials,
xhrFields: {
'withCredentials': true
},
headers: JSON.parse($("#external_headers").val()),
success: function(data){
$("#ifm").attr('src', $("#external_url").val());
//var win = window.open($("#external_url").val());
},
error: function(xhr, text, error) {
alert(text + ":" + error);
}
});


});
28 changes: 27 additions & 1 deletion js/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions js/templates/site.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<a class="icon-more" href="#"></a>

<div class="options hidden">
<div>
<label>
<span>{{authTXT}}</span>
<input type="text" name="site-loginurl" class="site-auth trigger-save" value="" style="width: 160px;" />
<input type="text" name="site-login" class="site-auth trigger-save" value="" style="width: 160px;" />
<input type="password" name="site-password" class="site-auth trigger-save" value="" style="width: 160px;" />
<input type="text" name="site-headers" class="site-auth trigger-save" value="" style="width: 160px;" />
</label>
</div>
<div>
<label>
<span>{{languageTXT}}</span>
Expand Down
5 changes: 5 additions & 0 deletions l10n/en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ OC.L10N.register(
{
"Name" : "Name",
"URL" : "URL",
"Auth" : "Authorization",
"Login" : "Login",
"LoginUrl" : "Login URL",
"Password" : "Password",
"Headers" : "Headers",
"Language" : "Language",
"Groups" : "Groups",
"Devices" : "Devices",
Expand Down
7 changes: 6 additions & 1 deletion l10n/en_GB.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{ "translations": {
"Name" : "Name",
"URL" : "URL",
"Auth" : "Auth",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Auth" : "Auth",
"Auth" : "Authorization",

For coherence with i18n/en_GB.js

"LoginUrl" : "Login URL",
"Login" : "Login",
"Password" : "Password",
"Language" : "Language",
"Headers" : "Headers",
"Groups" : "Groups",
"Devices" : "Devices",
"Icon" : "Icon",
Expand Down Expand Up @@ -50,4 +55,4 @@
"Uploading an icon with the same name will replace the current icon." : "Uploading an icon with the same name will replace the current icon.",
"Upload new icon" : "Upload new icon"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
}
7 changes: 6 additions & 1 deletion l10n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ OC.L10N.register(
{
"Name" : "Nom",
"URL" : "URL",
"Language" : "Langue",
"Auth" : "Autorisation",
"LoginUrl" : "URL",
"Login" : "Identifiant",
"Password" : "Mot de passe",
"Headers" : "En-tête",
"Language" : "Langue",
"Groups" : "Groupes",
"Devices" : "Appareils",
"Icon" : "Icône",
Expand Down
7 changes: 6 additions & 1 deletion l10n/fr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{ "translations": {
"Name" : "Nom",
"URL" : "URL",
"Auth" : "Authorisation",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Auth" : "Authorisation",
"Auth" : "Autorisation",

Or maybe "Authentification" ?

"LoginUrl" : "URL",
"Login" : "Identifiant",
"Password" : "Mot de passe",
"Headers" : "En-tête",
"Language" : "Langue",
"Groups" : "Groupes",
"Devices" : "Appareils",
Expand Down Expand Up @@ -51,4 +56,4 @@
"Uploading an icon with the same name will replace the current icon." : "Téléverser une icône avec le même nom va remplacer l'icône actuel.",
"Upload new icon" : "Téléverser une nouvelle icône"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}
}
16 changes: 12 additions & 4 deletions lib/Controller/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public function getAdmin() {
/**
* @param string $name
* @param string $url
* @param string $loginurl
* @param string $login
* @param string $password
* @param string $headers
* @param string $lang
* @param string $type
* @param string $device
Expand All @@ -154,9 +158,9 @@ public function getAdmin() {
* @param int $redirect
* @return DataResponse
*/
public function add($name, $url, $lang, $type, $device, $icon, array $groups, $redirect) {
public function add($name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, array $groups, $redirect) {
try {
return new DataResponse($this->sitesManager->addSite($name, $url, $lang, $type, $device, $icon, $groups, (bool) $redirect));
return new DataResponse($this->sitesManager->addSite($name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, $groups, (bool) $redirect));
} catch (InvalidNameException $e) {
return new DataResponse(['error' => $this->l->t('The given label is invalid'), 'field' => 'name'], Http::STATUS_BAD_REQUEST);
} catch (InvalidURLException $e) {
Expand All @@ -178,6 +182,10 @@ public function add($name, $url, $lang, $type, $device, $icon, array $groups, $r
* @param int $id
* @param string $name
* @param string $url
* @param string $loginurl
* @param string $login
* @param string $password
* @param string $headers
* @param string $lang
* @param string $type
* @param string $device
Expand All @@ -186,9 +194,9 @@ public function add($name, $url, $lang, $type, $device, $icon, array $groups, $r
* @param int $redirect
* @return DataResponse
*/
public function update($id, $name, $url, $lang, $type, $device, $icon, array $groups, $redirect) {
public function update($id, $name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, array $groups, $redirect) {
try {
return new DataResponse($this->sitesManager->updateSite($id, $name, $url, $lang, $type, $device, $icon, $groups, (bool) $redirect));
return new DataResponse($this->sitesManager->updateSite($id, $name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, $groups, (bool) $redirect));
} catch (SiteNotFoundException $e) {
return new DataResponse(['error' => $this->l->t('The site does not exist'), 'field' => 'site'], Http::STATUS_NOT_FOUND);
} catch (InvalidNameException $e) {
Expand Down
6 changes: 6 additions & 0 deletions lib/Controller/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,17 @@ protected function createResponse($id, array $site) {

$response = new TemplateResponse('external', 'frame', [
'url' => $site['url'],
'loginurl' => $site['loginurl'],
//'authsecret' => base64_encode($site['login']. ":" . $site['password']),
'username' => $site['login'],
'password' => $site['password'],
'headers' => $site['headers'],
], 'user');

$policy = new ContentSecurityPolicy();
$policy->addAllowedChildSrcDomain('*');
$policy->addAllowedFrameDomain('*');
$policy->addAllowedConnectDomain('*');
$response->setContentSecurityPolicy($policy);

return $response;
Expand Down
20 changes: 18 additions & 2 deletions lib/SitesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ protected function fillSiteArray(array $site) {
/**
* @param string $name
* @param string $url
* @param string $loginurl
* @param string $login
* @param string $password
* @param string $headers
* @param string $lang
* @param string $type
* @param string $device
Expand All @@ -212,7 +216,7 @@ protected function fillSiteArray(array $site) {
* @throws GroupNotFoundException
* @throws IconNotFoundException
*/
public function addSite($name, $url, $lang, $type, $device, $icon, array $groups, $redirect) {
public function addSite($name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, array $groups, $redirect) {
$id = 1 + (int) $this->config->getAppValue('external', 'max_site', 0);

if ($name === '') {
Expand Down Expand Up @@ -269,6 +273,10 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups
'id' => $id,
'name' => $name,
'url' => $url,
'loginurl' => $loginurl,
'login' => $login,
'password' => $password,
'headers' => $headers,
'lang' => $lang,
'type' => $type,
'device' => $device,
Expand All @@ -286,6 +294,10 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups
* @param int $id
* @param string $name
* @param string $url
* @param string $loginurl
* @param string $login
* @param string $password
* @param string $headers
* @param string $lang
* @param string $type
* @param string $device
Expand All @@ -302,7 +314,7 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups
* @throws GroupNotFoundException
* @throws IconNotFoundException
*/
public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array $groups, $redirect) {
public function updateSite($id, $name, $url, $loginurl, $login, $password, $headers, $lang, $type, $device, $icon, array $groups, $redirect) {
$sites = $this->getSites();
if (!isset($sites[$id])) {
throw new SiteNotFoundException();
Expand Down Expand Up @@ -361,6 +373,10 @@ public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array
'id' => $id,
'name' => $name,
'url' => $url,
'loginurl' => $loginurl,
'login' => $login,
'password' => $password,
'headers' => $headers,
'lang' => $lang,
'type' => $type,
'device' => $device,
Expand Down
6 changes: 6 additions & 0 deletions templates/frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@

/** @var array $_ */
?>
<!-- <input type="hidden" id="external_authsecret" value="<?php p($_['authsecret']); ?>" /> -->
<input type="hidden" id="external_url" value="<?php p($_['url']); ?>" />
<input type="hidden" id="external_loginurl" value="<?php p($_['loginurl']); ?>" />
<input type="hidden" id="external_username" value="<?php p($_['username']); ?>" />
<input type="hidden" id="external_password" value="<?php p($_['password']); ?>" />
<input type="hidden" id="external_headers" value="<?php p($_['headers']); ?>" />
<iframe id="ifm" src="<?php p($_['url']); ?>"></iframe>