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

Allow opportunistic loading of preset addressbook #233

Closed
t2d opened this issue Aug 17, 2018 · 12 comments
Closed

Allow opportunistic loading of preset addressbook #233

t2d opened this issue Aug 17, 2018 · 12 comments
Assignees
Labels

Comments

@t2d
Copy link

t2d commented Aug 17, 2018

First, I want to thank you for the nice plugin. However, I'm having a problem. I want to provide users their CardDAV-addressbook from Nextcloud. My config looks like this:

$prefs['Personal'] = array(
    'name'         =>  'Nextcloud',
    'username'     =>  '%u',
    'password'     =>  '%p',
    'url'          =>  'https://example.org:443/remote.php/dav/addressbooks/users/%u/contacts/',
    'active'       =>  true,
    'readonly'     =>  false,
    'refresh_time' => '01:00:00',

    'fixed'        =>  array( 'name', 'username', 'password' ),
    'hide'        =>  false,
);

But, if a user has not logged in Nextcloud before, the url is not valid. The user is therefore not able to log into Roundcube. Would it be possible to just mount the addressbook if present and proceed without otherwise?

@t2d t2d changed the title Not able to install if user url is not present Not able to log in if url is not present Aug 17, 2018
@kevo-gt
Copy link

kevo-gt commented Aug 29, 2018

Hi,
I had a similar issue that I managed to fix after looking at the carddav log in debug mode. If you have not turned on debug mode, edit carddav_common.php and find the line with debug and set to true:

const DEBUG = true;
const DEBUG_HTTP = true;

then check the "roundcube_path/logs/carddav.log"

@t2d
Copy link
Author

t2d commented Apr 1, 2019

The debug log tells me the same.

DISCOVERY: (retrieve_addressbooks) Searching additional URL: https://cloud.example.org:443/remote.php/dav/addressbooks/users/%u/contacts/
DISCOVERY: (retrieve_addressbooks) SEARCHING https://cloud.example.org:443/remote.php/dav/addressbooks/users/%u/contacts/ (Depth: 1)
DISCOVERY: (cdfopen) retrieve_addressbooks requesting https://cloud.example.org:443/remote.php/dav/addressbooks/users/user@example.org/contacts/ as user user@example.org[RL 5]
BACKEND: (update_addressbook) UPDATE addressbook
DISCOVERY: (cdfopen) Code: 401
DISCOVERY: (cdfopen) success: array (#012  'status' => 401,#012  'headers' => #012  Httpful\Response\Headers0:0:0:0:0:0:0:0__set_state(array(#012     'headers' => #012    array (#012      'date' => 'Mon, 01 Apr 2019 09:23:29 GMT',#012      'server' => 'Apache',#012      'expires' => 'Thu, 19 Nov 1981 08:52:00 GMT',#012      'cache-control' => 'no-store, no-cache, must-revalidate',#012      'pragma' => 'no-cache',#012      'x-frame-options' => 'SAMEORIGIN',#012      'content-security-policy' => 'default-src \'none\';',#012      'www-authenticate' => 'Basic realm="cloud.example.org", charset="UTF-8"',#012      'set-cookie' => 'ocx3onqumo2o=vfh8for84h6glh2jjft9khkgn2; path=/; secure; HttpOnly',#012      'strict-transport-security' => 'max-age=31536000;includeSubdomains',#012      'upgrade' => 'h2',#012      'connection' => 'Upgrade',#012      'x-content-type-options' => 'nosniff',#012      'x-xss-protection' => '1; mode=block',#012      'referrer-policy' => 'no-referrer',#012      'x-robots-tag' => 'none',#012      'x-download-options' => 'noopen',#012      'x-permitted-cross-domain-policies' => 'none',#012      'transfer-encoding' => 'chunked',#012      'content-type' => 'application/xml; charset=utf-8',#012    ),#012  )),#012  'body' => '<?xml version="1.0" encoding="utf-8"?>#012<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">#012  <s:exception>Sabre\\DAV\\Exception\\NotAuthenticated</s:exception>#012  <s:message>No public access to this resource., Username or password was incorrect, No \'Authorization: Bearer\' header found. Either the client didn\'t send one, or the server is mis-configured, Username or password was incorrect</s:message>#012</d:error>#012',#012)

If the addressbook lookup fails, the client gets a 500 Server Error.
It would be great, if the plugin could mount the opportunistically addressbook if it exist and continue otherwise.

@t2d t2d changed the title Not able to log in if url is not present Allow opportunistic loading of preset addressbook Apr 1, 2019
@blind-coder
Copy link
Collaborator

There's really two issues here:
The first being that Nextcloud does not provision the user through the CardDAV API call (same as ownCloud, btw), and the second being that you're asking RCMCardDAV to simply ignore what is clearly reported to it as an error.
While there is no excuse for the former, the latter is something I can actually do something about.
I have applied a possible fix in the branch issue_233, can you test that?

@t2d
Copy link
Author

t2d commented Aug 13, 2019

Thank you for attending this issue. With branch issues_233 users can still log in, even if the preset addressbook is impossible to fetch.

@blind-coder
Copy link
Collaborator

And by "log in" you mean that roundcube works correctly as well?

@t2d
Copy link
Author

t2d commented Aug 13, 2019

Yes, that's what I mean. it works great. Thank you.
My working config with nextcloud looks like:

$prefs['Personal'] = array(
    'name'         =>  'Nextcloud',
    'username'     =>  '%u',
    'password'     =>  '%p',
    'url'          =>  'https://example.org:443/remote.php/dav/addressbooks/users/%l/contacts/',
    'active'       =>  true,
    'readonly'     =>  false,
    'refresh_time' => '01:00:00',

    'fixed'        =>  array( 'name', 'username', 'password' ),
    'hide'        =>  false,
);

I had to use %l in url because my instance doesn't use a domain part in contrast to roundcube.

@blind-coder
Copy link
Collaborator

Great, thank you for the feedback! I'll merge this into master and a release soon.

@doobry-systemli
Copy link

I can confirm that @blind-coder's fix in branch issue_233 works. Would be awesome if it could be merged and released soon.

@532910
Copy link

532910 commented Nov 10, 2019

I have the same issue: if there is no addressbook on radicale server for the user it will not be able to login roundcube.

@doobry-systemli
Copy link

@blind-coder: is there a chance to get this merged anytime soon?

@t2d
Copy link
Author

t2d commented Mar 14, 2020

Hey, can you please bring this to the main branch?

@mstilkerich mstilkerich self-assigned this Jul 26, 2020
@mstilkerich
Copy link
Owner

I believe this issue is fixed in the current master. If the discovery process fails for presets, nothing will be added. If you nevertheless still encounter the issue, please comment / reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants