Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move BasicAuth check to isLoggedIn #11158

Merged
merged 1 commit into from
Sep 19, 2014
Merged

Move BasicAuth check to isLoggedIn #11158

merged 1 commit into from
Sep 19, 2014

Conversation

LukasReschke
Copy link
Member

Ensures that Basic Auth works properly for APIs and removes the need for some even uglier lines of code.

Related to #11155 (comment) and needs a backport to stable7.

@PVince81 @DeepDiver1975 @karlitschek Testing welcome. Especially the APIs (e.g. curl -D - http://admin:admin@localhost/core/index.php/apps/files/api/v1/thumbnail/100/100/welcome.txt) and #11129

Ensures that Basic Auth works properly for APIs and removes the need for some even uglier lines of code.
@scrutinizer-notifier
Copy link

A new inspection was created.

@LukasReschke
Copy link
Member Author

Expected behaviour:

If valid Basic Authentication header is set:

  • Resource is served
  • Set a valid cookie

If invalid Basic Authentication header is set:

  • User is not logged-in (error / login page)

@karlitschek
Copy link
Contributor

Hmm. In case of API requests no login page should be returned but only the proper http response code. Or am I missing something?

@LukasReschke
Copy link
Member Author

Yes. That is also the expected behaviour ;-)

@karlitschek
Copy link
Contributor

We also only want to backport critical security problem. What is the reason here?

@LukasReschke
Copy link
Member Author

We also only want to backport critical security problem. What is the reason here?

Regression with #11130 that lead to the case that only a valid cookie is returned for API requests and the resource is not served. This was not the wanted behaviour and potentially breaks clients that are not using the cookie.

@PVince81
Copy link
Contributor

It's worse than that: bypassing the login hook through this bug disables encryption for files. So files get uploaded unencrypted...

@PVince81
Copy link
Contributor

Ok sorry, mixed up with the other basic auth fix PR...

@LukasReschke
Copy link
Member Author

Yeah - that is "only" a bug fix for the other PR which is merged ;-)

@LukasReschke
Copy link
Member Author

Because you can't touch things in base.php without breaking other things - I now moved the Basic Auth login check into "isLoggedIn()" where it makes more sense...

@@ -780,15 +780,6 @@ public static function handleRequest() {
if (isset($_COOKIE['oc_token'])) {
OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
}
if (isset($_SERVER['PHP_AUTH_USER'])) {
Copy link
Member

Choose a reason for hiding this comment

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

@LukasReschke please double check the git history here - this was added on purpose to enable some scenarios.

Looks like I'm loosing track of all the reasons why stuff was changed ......

Copy link
Member Author

Choose a reason for hiding this comment

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

This was added with 4ddf5d9 and is not necessary anymore. Login and logout works also now with invalid basic auth credentials.

Logout is not something that we can control do due to Basic Auth though, if somebody decides to access ownCloud via Basic Auth the credentials are sent by the browser - nothing we can control.

@karlitschek
Copy link
Contributor

O.K. Thanks for the explanation. 👍

@ghost
Copy link

ghost commented Sep 18, 2014

💣 Test Failed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org/job/pull-request-analyser/7457/

@LukasReschke LukasReschke changed the title Move BasicAuth check to "isLoggedIn()" Move BasicAuth check to isLoggedIn Sep 18, 2014
@LukasReschke
Copy link
Member Author

Let's try again .... great software...

@LukasReschke
Copy link
Member Author

@owncloud-bot Retest this please

@ghost
Copy link

ghost commented Sep 19, 2014

🚀 Test Passed. 🚀
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org/job/pull-request-analyser/7468/

@BernhardPosselt
Copy link
Contributor

👍 fixes login issues with the news app on android

LukasReschke added a commit that referenced this pull request Sep 19, 2014
Move BasicAuth check to isLoggedIn
@LukasReschke LukasReschke merged commit 4c6bad7 into master Sep 19, 2014
@LukasReschke LukasReschke deleted the fix_basic_auth branch September 19, 2014 11:39
@LukasReschke
Copy link
Member Author

Stable7: 37632e4

@BernhardPosselt
Copy link
Contributor

@danimo maybe this also fixes your auth issue

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants