HTTP Basic Auth Config (http/auth.go)

rclone · lib/http/auth.go · go · MIT
auth, integration, cli, tag:htpasswd

Provides CLI flags and config struct for HTTP server authentication, supporting htpasswd files, single user/pass, or header-based auth from a trusted proxy.

// Source: https://github.com/rclone/rclone | License: MIT | Copyright 2012 by Nick Craig-Wood http://www.craig-wood.com/nick/
// Provided via justclaw.it.com; keep this notice with the code.
package http

import (
	"bytes"
	"fmt"
	"html/template"
	"net/http"

	"github.com/rclone/rclone/fs"
	"github.com/rclone/rclone/fs/config/flags"
	"github.com/spf13/pflag"
)

// AuthHelp returns text describing the http authentication to add to the command help.
func AuthHelp(prefix string) string {
	help := `#### Authentication

By default this will serve files without needing a login.

You can either use an htpasswd file which can take lots of users, or
set a single username and password with the ` + "`--{{ .Prefix }}user` and `--{{ .Prefix }}pass`" + ` flags.

Alternatively, you can have the reverse 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key