app password scope wip

Signed-off-by: Robin Appelman <icewind@owncloud.com>
pull/719/head
Robin Appelman 8 years ago committed by Robin Appelman
parent 2389e0f250
commit b4e27d35f5
No known key found for this signature in database
GPG Key ID: 425003AC385454C5
  1. 6
      lib/private/Authentication/Token/DefaultToken.php
  2. 1
      lib/private/Authentication/Token/DefaultTokenMapper.php
  3. 14
      lib/private/Authentication/Token/IToken.php
  4. 10
      settings/css/settings.css
  5. 17
      settings/js/authtoken_view.js
  6. 1
      settings/templates/personal.php

@ -151,6 +151,10 @@ class DefaultToken extends Entity implements IToken {
} }
public function setScope($scope) { public function setScope($scope) {
return parent::setScope(json_encode($scope)); if (is_string($scope)) {
$this->scope = $scope;
} else {
return parent::setScope(json_encode($scope));
}
} }
} }

@ -83,6 +83,7 @@ class DefaultTokenMapper extends Mapper {
if ($data === false) { if ($data === false) {
throw new DoesNotExistException('token does not exist'); throw new DoesNotExistException('token does not exist');
} }
;
return DefaultToken::fromRow($data); return DefaultToken::fromRow($data);
} }

@ -67,13 +67,25 @@ interface IToken extends JsonSerializable {
public function getLastCheck(); public function getLastCheck();
/** /**
* Get the timestamp of the last password check * Set the timestamp of the last password check
* *
* @param int $time * @param int $time
*/ */
public function setLastCheck($time); public function setLastCheck($time);
/**
* Get the authentication scope for this token
*
* If the scope is null no limitations exist for the token
*
* @return array|null
*/
public function getScope(); public function getScope();
/**
* Set the authentication scope for this token
*
* @param array|null $scope
*/
public function setScope($scope); public function setScope($scope);
} }

@ -149,6 +149,12 @@ table.nostyle td { padding: 0.2em 0; }
padding: 10px 10px 10px 0; padding: 10px 10px 10px 0;
} }
#sessions .token-list td.icon,
#apppasswords .token-list td.icon {
width: 16px;
padding: 10px;
}
#sessions .token-list td, #sessions .token-list td,
#apppasswords .token-list td { #apppasswords .token-list td {
border-top: 1px solid #DDD; border-top: 1px solid #DDD;
@ -162,8 +168,8 @@ table.nostyle td { padding: 0.2em 0; }
#apppasswords tr *:nth-child(2) { #apppasswords tr *:nth-child(2) {
text-align: right; text-align: right;
} }
#sessions .token-list td a.icon-delete, #sessions .token-list td a.icon,
#apppasswords .token-list td a.icon-delete { #apppasswords .token-list td a.icon {
display: block; display: block;
opacity: 0.6; opacity: 0.6;
} }

@ -29,11 +29,16 @@
'<tr data-id="{{id}}">' '<tr data-id="{{id}}">'
+ '<td class="has-tooltip" title="{{title}}"><span class="token-name">{{name}}</span></td>' + '<td class="has-tooltip" title="{{title}}"><span class="token-name">{{name}}</span></td>'
+ '<td><span class="last-activity has-tooltip" title="{{lastActivityTime}}">{{lastActivity}}</span></td>' + '<td><span class="last-activity has-tooltip" title="{{lastActivityTime}}">{{lastActivity}}</span></td>'
+ '<td class="icon">'
+ '{{#if canScope}}'
+ '<a class="icon icon-settings has-tooltip" title="' + t('core', 'Configure') + '"></a>'
+ '{{/if}}'
+ '</td>'
+ '<td class="icon">'
+ '{{#if canDelete}}' + '{{#if canDelete}}'
+ '<td><a class="icon-delete has-tooltip" title="' + t('core', 'Disconnect') + '"></a></td>' + '<a class="icon icon-delete has-tooltip" title="' + t('core', 'Disconnect') + '"></a>'
+ '{{else}}'
+ '<td></td>'
+ '{{/if}}' + '{{/if}}'
+ '</td>'
+ '<tr>'; + '<tr>';
var SubView = OC.Backbone.View.extend({ var SubView = OC.Backbone.View.extend({
@ -78,7 +83,7 @@
this._toggleHeader(tokens.length > 0); this._toggleHeader(tokens.length > 0);
tokens.forEach(function (token) { tokens.forEach(function (token) {
var viewData = this._formatViewData(token.toJSON()); var viewData = this._formatViewData(token);
var html = _this.template(viewData); var html = _this.template(viewData);
var $html = $(html); var $html = $(html);
$html.find('.has-tooltip').tooltip({container: 'body'}); $html.find('.has-tooltip').tooltip({container: 'body'});
@ -94,10 +99,12 @@
this.$('.hidden-when-empty').toggleClass('hidden', !show); this.$('.hidden-when-empty').toggleClass('hidden', !show);
}, },
_formatViewData: function (viewData) { _formatViewData: function (token) {
var viewData = token.toJSON();
var ts = viewData.lastActivity * 1000; var ts = viewData.lastActivity * 1000;
viewData.lastActivity = OC.Util.relativeModifiedDate(ts); viewData.lastActivity = OC.Util.relativeModifiedDate(ts);
viewData.lastActivityTime = OC.Util.formatDate(ts, 'LLL'); viewData.lastActivityTime = OC.Util.formatDate(ts, 'LLL');
viewData.canScope = token.get('type') === '1';
// preserve title for cases where we format it further // preserve title for cases where we format it further
viewData.title = viewData.name; viewData.title = viewData.name;

@ -220,6 +220,7 @@ if($_['passwordChangeSupported']) {
<th><?php p($l->t('Name'));?></th> <th><?php p($l->t('Name'));?></th>
<th><?php p($l->t('Last activity'));?></th> <th><?php p($l->t('Last activity'));?></th>
<th></th> <th></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody class="token-list icon-loading"> <tbody class="token-list icon-loading">

Loading…
Cancel
Save