Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
61d53598
Commit
61d53598
authored
12 years ago
by
Michiel de Jong
Browse files
Options
Downloads
Patches
Plain Diff
clean up auth dialog
parent
2e309aae
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
apps/remoteStorage/appinfo/webfinger.php
+1
-1
1 addition, 1 deletion
apps/remoteStorage/appinfo/webfinger.php
apps/remoteStorage/auth.php
+27
-51
27 additions, 51 deletions
apps/remoteStorage/auth.php
with
28 additions
and
52 deletions
apps/remoteStorage/appinfo/webfinger.php
+
1
−
1
View file @
61d53598
...
...
@@ -3,6 +3,6 @@
rel=
"remoteStorage"
template=
"
<?php
echo
WF_BASEURL
;
?>
/apps/remoteStorage/WebDAV.php/
<?php
echo
WF_USER
;
?>
/remoteStorage/{category}/"
api=
"WebDAV"
auth=
"
<?php
echo
WF_BASEURL
;
?>
/?app=remoteStorage&getfile=auth.php
/
<?php
echo
WF_USER
;
?>
"
>
auth=
"
<?php
echo
WF_BASEURL
;
?>
/?app=remoteStorage&getfile=auth.php
&userid=
<?php
echo
WF_USER
;
?>
"
>
</Link>
<?php
}
?>
This diff is collapsed.
Click to expand it.
apps/remoteStorage/auth.php
+
27
−
51
View file @
61d53598
...
...
@@ -29,19 +29,8 @@
// Do not load FS ...
$RUNTIME_NOSETUPFS
=
true
;
require_once
(
'../../lib/base.php'
);
require_once
(
'../../lib/user.php'
);
require_once
(
'../../lib/public/user.php'
);
require_once
(
'../../lib/app.php'
);
require_once
(
'../../lib/public/app.php'
);
require_once
(
'../../3rdparty/Sabre/DAV/Auth/IBackend.php'
);
require_once
(
'../../3rdparty/Sabre/DAV/Auth/Backend/AbstractBasic.php'
);
require_once
(
'../../lib/connector/sabre/auth.php'
);
OCP\App
::
checkAppEnabled
(
'remoteStorage'
);
require_once
(
'Sabre/autoload.php'
);
require_once
(
'lib_remoteStorage.php'
);
require_once
(
'oauth_ro_auth.php'
);
...
...
@@ -49,32 +38,27 @@ ini_set('default_charset', 'UTF-8');
#ini_set('error_reporting', '');
@
ob_clean
();
$path
=
substr
(
$_SERVER
[
"REQUEST_URI"
],
strlen
(
$_SERVER
[
"SCRIPT_NAME"
]));
$pathParts
=
explode
(
'/'
,
$path
);
if
(
count
(
$pathParts
)
==
2
&&
$pathParts
[
0
]
==
''
)
{
//TODO: input checking. these explodes may fail to produces the desired arrays:
$subPathParts
=
explode
(
'?'
,
$pathParts
[
1
]);
$ownCloudUser
=
$subPathParts
[
0
];
foreach
(
$_GET
as
$k
=>
$v
)
{
if
(
$k
==
'user_address'
){
$userAddress
=
$v
;
}
else
if
(
$k
==
'redirect_uri'
){
$appUrlParts
=
explode
(
'/'
,
$v
);
$appUrl
=
$appUrlParts
[
2
];
//bit dodgy i guess
}
else
if
(
$k
==
'scope'
){
$categories
=
$v
;
}
}
$currUser
=
OCP\USER
::
getUser
();
if
(
$currUser
==
$ownCloudUser
)
{
if
(
isset
(
$_POST
[
'allow'
]))
{
//TODO: check if this can be faked by editing the cookie in firebug!
$token
=
OC_remoteStorage
::
createCategories
(
$appUrl
,
$categories
);
header
(
'Location: '
.
$_GET
[
'redirect_uri'
]
.
'#access_token='
.
$token
.
'&token_type=bearer'
);
}
else
if
(
$existingToken
=
OC_remoteStorage
::
getTokenFor
(
$appUrl
,
$categories
))
{
header
(
'Location: '
.
$_GET
[
'redirect_uri'
]
.
'#access_token='
.
$existingToken
.
'&token_type=bearer'
);
}
else
{
foreach
(
$_GET
as
$k
=>
$v
)
{
if
(
$k
==
'userid'
){
$userId
=
$v
;
}
else
if
(
$k
==
'redirect_uri'
){
$appUrlParts
=
explode
(
'/'
,
$v
);
$appUrl
=
$appUrlParts
[
2
];
//bit dodgy i guess
}
else
if
(
$k
==
'scope'
){
$categories
=
$v
;
}
}
$currUser
=
OCP\USER
::
getUser
();
if
(
$userId
&&
$appUrl
&&
$categories
)
{
if
(
$currUser
==
$userId
)
{
if
(
isset
(
$_POST
[
'allow'
]))
{
//TODO: check if this can be faked by editing the cookie in firebug!
$token
=
OC_remoteStorage
::
createCategories
(
$appUrl
,
$categories
);
header
(
'Location: '
.
$_GET
[
'redirect_uri'
]
.
'#access_token='
.
$token
.
'&token_type=bearer'
);
}
else
if
(
$existingToken
=
OC_remoteStorage
::
getTokenFor
(
$appUrl
,
$categories
))
{
header
(
'Location: '
.
$_GET
[
'redirect_uri'
]
.
'#access_token='
.
$existingToken
.
'&token_type=bearer'
);
}
else
{
//params ok, logged in ok, but need to click Allow still:
?>
<!DOCTYPE html>
<html>
...
...
@@ -125,22 +109,14 @@ if(count($pathParts) == 2 && $pathParts[0] == '') {
</body>
</html>
<?php
}
}
else
{
if
((
isset
(
$_SERVER
[
'HTTPS'
]))
&&
(
$_SERVER
[
'HTTPS'
]))
{
$url
=
"https://"
;
}
else
{
$url
=
"http://"
;
}
$url
.
=
$_SERVER
[
'SERVER_NAME'
];
$url
.
=
substr
(
$_SERVER
[
'SCRIPT_NAME'
],
0
,
-
strlen
(
'apps/remoteStorage/compat.php'
));
}
//end 'need to click Allow still'
}
else
{
//login not ok
if
(
$currUser
)
{
die
(
'You are logged in as '
.
$currUser
.
' instead of '
.
$
ownCloudU
ser
);
die
(
'You are logged in as '
.
$currUser
.
' instead of '
.
$
u
ser
Id
);
}
else
{
header
(
'Location: /?redirect_url='
.
urlencode
(
'/apps/remoteStorage/auth.php'
.
$_SERVER
[
'PATH_INFO'
]
.
'?'
.
$_SERVER
[
'QUERY_STRING'
]));
}
}
}
else
{
//die('please use auth.php/username?params. '.var_export($pathParts, true));
die
(
'please use auth.php/username?params.'
);
}
else
{
//params not ok
die
(
'please use e.g. /?app=remoteStorage&getfile=auth.php&userid=admin'
);
}
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