Using Auth Proxy just to determine root in existing remote?

Hi all,

I'm trying to serve files on a Google Drive based remote via rsync serve webdav and I'd like to treat this similar to /home on Unix, where each user can only access their own directory. For example, foo can only see the contents of the folder named foo on Google Drive (and admin can see everything).

If I understand correctly, I can use Auth Proxy for this, where my proxy authenticates the user and then returns a config where _root is the same as the username. However, if I understand correctly, my proxy would need to return everything Google Drive needs, including client_id, client_secret, token etc.

Is there a way to avoid this? Can an Auth Proxy just say "use the existing remote, but change _root"?

Is there a better / easier way to achieve what I want?

If it were me I'd toss a reverse proxy in front like Caddy. And have it manage all of that. But to be fair I haven't experimented with using auth proxy via rclone.

EDIT: looking at the docs and example though you can just return the same id and secret for each user and just change the root.

Yes that is right.

Also correct...

The auth proxy can't currently say base the remaining parameters off this remote.

You can read remotes via the remote control though so you could do it programatically

$ rclone rc --loopback config/get name=z
{
	"token": "{\"access_token\":\"XXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}",
	"type": "pcloud"
}

Thanks, rclone rc solves this perfectly!

If anyone else ever wants to do this, here's my auth proxy:

#!/bin/bash

input="$(cat)"
username="$(echo "$input" | jq -r '.user')"
password="$(echo "$input" | jq -r '.pass')"
root="$username"
if [[ "$username" == "admin" ]]; then
    root=""
fi
htpasswd -vb "<file with users>" "$username" "$password" &> /dev/null || exit 1
rclone rc --loopback config/get name=<name of remote> | jq "._root = \"$root\""
2 Likes

Very neat! I like your use of jq - very useful in bash scripts.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.