Let a Core keep a token for one owner's apps on a host
coreapp login <host>/<owner> saves a token used for that owner's repositories and images before the host's token, so apps from different accounts on one host can use different tokens. git sends it only under https://<host>/<owner>/; docker gets it for that pull only. Errors name the token that was tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+23
-12
@@ -42,8 +42,10 @@
|
||||
# installed one)
|
||||
# coreapp update <name> update an app installed from a repository to its
|
||||
# newest release
|
||||
# coreapp login <host> give the Core a token for private apps from host
|
||||
# (asks for the user and token); logout <host>,
|
||||
# coreapp login <host>[/<owner>]
|
||||
# give the Core a token for private apps from host
|
||||
# (asks for the user and token; with /<owner>, for
|
||||
# that owner's apps only); logout <host>[/<owner>],
|
||||
# logins: forget one, list them
|
||||
# coreapp publish [--platform <list>]
|
||||
# build the release image and push it to the
|
||||
@@ -519,12 +521,20 @@ cmd_update() {
|
||||
}
|
||||
|
||||
cmd_login() {
|
||||
local host="${1:-}" user token
|
||||
[[ $# -eq 1 && "$host" =~ ^[a-z0-9][a-z0-9.:-]*$ ]] \
|
||||
|| die "Usage: coreapp login <host> (e.g. coreapp login gitea.federated.computer)"
|
||||
echo "The Core in '$VM' keeps this token to install private apps from $host:"
|
||||
echo "their repositories and images. For Gitea, make a token for it with read"
|
||||
echo "access to repositories and packages (Settings > Applications)."
|
||||
local key="${1:-}" host user token
|
||||
[[ $# -eq 1 && "$key" =~ ^[A-Za-z0-9][A-Za-z0-9.:-]*(/[A-Za-z0-9][A-Za-z0-9._-]*)?$ ]] \
|
||||
|| die "Usage: coreapp login <host>[/<owner>] (e.g. coreapp login gitea.federated.computer, or gitea.federated.computer/my-team for one owner's apps)"
|
||||
host="${key%%/*}"
|
||||
if [[ "$key" == */* ]]; then
|
||||
echo "The Core in '$VM' keeps this token to install private apps from ${key#*/}"
|
||||
echo "on $host (their repositories and images); other owners' apps there use"
|
||||
echo "the token for $host, if it has one."
|
||||
else
|
||||
echo "The Core in '$VM' keeps this token to install private apps from $host:"
|
||||
echo "their repositories and images."
|
||||
fi
|
||||
echo "For Gitea, make a token for it with read access to repositories and"
|
||||
echo "packages (Settings > Applications)."
|
||||
read -r -p "User on $host: " user
|
||||
[[ "$user" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || die "'$user' isn't a user name."
|
||||
read -r -s -p "Token: " token
|
||||
@@ -532,15 +542,16 @@ cmd_login() {
|
||||
init_core
|
||||
sync_installer
|
||||
# On stdin, so it's never in a command line
|
||||
printf '%s\n' "$token" | core "$REMOTE_INSTALLER/coreapps login $host $user"
|
||||
printf '%s\n' "$token" | core "$REMOTE_INSTALLER/coreapps login $key $user"
|
||||
}
|
||||
|
||||
cmd_logout() {
|
||||
local host="${1:-}"
|
||||
[[ $# -eq 1 && "$host" =~ ^[a-z0-9][a-z0-9.:-]*$ ]] || die "Usage: coreapp logout <host>"
|
||||
local key="${1:-}"
|
||||
[[ $# -eq 1 && "$key" =~ ^[A-Za-z0-9][A-Za-z0-9.:-]*(/[A-Za-z0-9][A-Za-z0-9._-]*)?$ ]] \
|
||||
|| die "Usage: coreapp logout <host>[/<owner>]"
|
||||
init_core
|
||||
sync_installer
|
||||
core "$REMOTE_INSTALLER/coreapps logout $host"
|
||||
core "$REMOTE_INSTALLER/coreapps logout $key"
|
||||
}
|
||||
|
||||
cmd_logins() {
|
||||
|
||||
Reference in New Issue
Block a user