Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
ca0fbaca
Unverified
Commit
ca0fbaca
authored
5 years ago
by
Roeland Jago Douma
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16882 from nextcloud/enh/apppassword_rotation
Allow rotation of apppasswords
parents
560b9851
cd1f4438
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/Controller/AppPasswordController.php
+24
-0
24 additions, 0 deletions
core/Controller/AppPasswordController.php
core/routes.php
+1
-0
1 addition, 0 deletions
core/routes.php
with
25 additions
and
0 deletions
core/Controller/AppPasswordController.php
+
24
−
0
View file @
ca0fbaca
...
...
@@ -138,4 +138,28 @@ class AppPasswordController extends \OCP\AppFramework\OCSController {
$this
->
tokenProvider
->
invalidateTokenById
(
$token
->
getUID
(),
$token
->
getId
());
return
new
DataResponse
();
}
/**
* @NoAdminRequired
*/
public
function
rotateAppPassword
():
DataResponse
{
if
(
!
$this
->
session
->
exists
(
'app_password'
))
{
throw
new
OCSForbiddenException
(
'no app password in use'
);
}
$appPassword
=
$this
->
session
->
get
(
'app_password'
);
try
{
$token
=
$this
->
tokenProvider
->
getToken
(
$appPassword
);
}
catch
(
InvalidTokenException
$e
)
{
throw
new
OCSForbiddenException
(
'could not rotate apptoken'
);
}
$newToken
=
$this
->
random
->
generate
(
72
,
ISecureRandom
::
CHAR_UPPER
.
ISecureRandom
::
CHAR_LOWER
.
ISecureRandom
::
CHAR_DIGITS
);
$this
->
tokenProvider
->
rotate
(
$token
,
$appPassword
,
$newToken
);
return
new
DataResponse
([
'apppassword'
=>
$newToken
,
]);
}
}
This diff is collapsed.
Click to expand it.
core/routes.php
+
1
−
0
View file @
ca0fbaca
...
...
@@ -107,6 +107,7 @@ $application->registerRoutes($this, [
[
'root'
=>
'/core'
,
'name'
=>
'WhatsNew#get'
,
'url'
=>
'/whatsnew'
,
'verb'
=>
'GET'
],
[
'root'
=>
'/core'
,
'name'
=>
'WhatsNew#dismiss'
,
'url'
=>
'/whatsnew'
,
'verb'
=>
'POST'
],
[
'root'
=>
'/core'
,
'name'
=>
'AppPassword#getAppPassword'
,
'url'
=>
'/getapppassword'
,
'verb'
=>
'GET'
],
[
'root'
=>
'/core'
,
'name'
=>
'AppPassword#rotateAppPassword'
,
'url'
=>
'/apppassword/rotate'
,
'verb'
=>
'POST'
],
[
'root'
=>
'/core'
,
'name'
=>
'AppPassword#deleteAppPassword'
,
'url'
=>
'/apppassword'
,
'verb'
=>
'DELETE'
],
[
'root'
=>
'/collaboration'
,
'name'
=>
'CollaborationResources#searchCollections'
,
'url'
=>
'/resources/collections/search/{filter}'
,
'verb'
=>
'GET'
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment