-
-
Save apollo13/f4fc8f33a2700dffb9e11c1b056c53ba to your computer and use it in GitHub Desktop.
[tool.poetry] | |
name = "owncloudemulator" | |
version = "0.1.0" | |
description = "" | |
authors = ["Florian Apolloner <[email protected]>"] | |
[tool.poetry.dependencies] | |
python = "^3.7" | |
starlette = "^0.13.0" | |
uvicorn = "^0.10.8" | |
[tool.poetry.dev-dependencies] | |
[build-system] | |
requires = ["poetry>=0.12"] | |
build-backend = "poetry.masonry.api" |
# This simple server emulates a owncloud server for gnome-online-accounts. | |
# It just redirects the DAV discovery to fastmail :D | |
from starlette.applications import Starlette | |
from starlette.routing import Route, Mount | |
from starlette.requests import Request | |
from starlette.responses import Response, RedirectResponse | |
async def homepage(request: Request): | |
return Response() | |
async def dav(request: Request): | |
mapping = { | |
"caldav": "https://caldav.fastmail.com/dav/calendars", | |
"carddav": "https://carddav.fastmail.com/dav/addressbooks", | |
} | |
return RedirectResponse(mapping[request.path_params["type"]]) | |
app = Starlette( | |
debug=False, | |
routes=[ | |
Route("/.well-known/{type}", dav, methods=["PROPFIND"]), | |
Mount( | |
"/remote.php", | |
routes=[ | |
Route("/webdav/", homepage), | |
Route("/{type}/", dav, methods=["PROPFIND"]), | |
], | |
), | |
], | |
) |
@duckwork I don't think that works since you cannot generate app passwords in fastmail (I just tried) which provide access to CardDav/CalDav & Files :( But if you are just using your normal password you might try adding the mapping and remove the Route in line 29.
FWIW I have asked the fastmail CEO if this could be added https://twitter.com/fapolloner/status/1254138648238448640
And even then it won't work because gvfs cannot follow redirects: https://gitlab.gnome.org/GNOME/gvfs/-/issues/177 :(
hmm.. thanks for the reply! I realized that for now, I can just add fastmail's files in Nautilus with davfs://
so that works well enough.
Thanks for the reply! AND for the message to Fastmail -- it should be an option, I think.
Yes, file integration from goa doesn't much more than that by itself anyways I think.
Thanks a lot !!!!!
This is so much better than using bloaty evolution for adding/removing contacts and calendar but using preinstalled gnome applications for viewing it.
(BTW, I rewrote it in Go because its leaner and installing it is easier (single systemd service and no venv) but whatever )
There is an upstream MR to get official support for CalDAV in gnome-online-accounts.
https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/merge_requests/54
Hopefully it gets reviewed and merged so workarounds aren't necessary.
I added a merge request for fastmail support a year ago with no response yet. If you look at the master https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/commits/master aside from translations there isn't happening anything since a while; I do not have any hopes and sadly have to assume that goa is abandonware.
The same, as dependency-less python3. Feel free to use (MIT).
#!/usr/bin/env python3
# Copyright (c) 2023 Philip Smith
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import os
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
HOST = os.getenv('HOST', 'localhost')
PORT = int(os.getenv('PORT', '8080'))
CALDAV = os.getenv('CALDAV', 'https://caldav.fastmail.com/dav/calendars')
CARDDAV = os.getenv('CARDDAV', 'https://carddav.fastmail.com/dav/addressbooks')
REDIRECTS = {
'/.well-known/caldav': CALDAV,
'/.well-known/carddav': CARDDAV,
'/remote.php/caldav/': CALDAV,
'/remote.php/carddav/': CARDDAV,
}
class Redirect(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/remote.php/webdav/':
self.send_response(200)
self.end_headers()
def do_PROPFIND(self):
location = REDIRECTS.get(self.path)
if location:
self.send_response(302)
self.send_header('Location', location)
self.end_headers()
ThreadingHTTPServer((HOST, PORT), Redirect).serve_forever()
The same, as dependency-less python3. Feel free to use (MIT).
#!/usr/bin/env python3 # Copyright (c) 2023 Philip Smith # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import os from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler HOST = os.getenv('HOST', 'localhost') PORT = int(os.getenv('PORT', '8080')) CALDAV = os.getenv('CALDAV', 'https://caldav.fastmail.com/dav/calendars') CARDDAV = os.getenv('CARDDAV', 'https://carddav.fastmail.com/dav/addressbooks') REDIRECTS = { '/.well-known/caldav': CALDAV, '/.well-known/carddav': CARDDAV, '/remote.php/caldav/': CALDAV, '/remote.php/carddav/': CARDDAV, } class Redirect(BaseHTTPRequestHandler): def do_GET(self): if self.path == '/remote.php/webdav/': self.send_response(200) self.end_headers() def do_PROPFIND(self): location = REDIRECTS.get(self.path) if location: self.send_response(302) self.send_header('Location', location) self.end_headers() ThreadingHTTPServer((HOST, PORT), Redirect).serve_forever()
@phs I have created a tool of my own based on this script. Basically I just added a config_file argument, to accept a config file that is used to set the CalDAV and CardDAV URLs. I have credited you for the script: https://gitlab.com/julianfairfax/gnome-dav-proxy#related-projects-and-alternatives, and my tool is licensed as MIT, as yours is: https://gitlab.com/julianfairfax/gnome-dav-proxy#license. Please let me know if any of this is a (licensing) issue for you, and I will do my best to rectify it.
Please let me know if any of this is a (licensing) issue for you, and I will do my best to rectify it.
Nope, go for it. And thanks for putting that together!
Hey! This works great; I'm curious about adding webdav (files) support as well. I'm guessing it's in the
dav()
functionmapping
.. would something like this work:? Thanks again for the great little tool!