keycloak

package
v0.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 10 Imported by: 0

README

Keycloak backend

This backend serves local directories to users authenticated by a Keycloak server. Each user gets their own <base_path>/<user name> directory.

Parameters

  • keycloak_url: The URL of the Keycloak server.
  • keycloak_realm: The realm of the users.
  • keycloak_client_id: The client ID. If it isn't set, the KEYCLOAK_CLIENT_ID environment variable is used.
  • keycloak_client_secret: The client secret. If it isn't set, the KEYCLOAK_CLIENT_SECRET environment variable is used.
  • base_path: The local directory containing the users' directories. Environment variables ($NAME) are replaced by their value.

The client must allow the "Direct Access Grants" (resource owner password credentials) flow, which is how the credentials sent by the FTP clients are checked.

Configuration

A keycloak access doesn't have any user or pass, it accepts any user that Keycloak authenticates. As accesses are evaluated in their declaration order, it should be declared last.

{
  "accesses": [
    {
      "fs": "keycloak",
      "params": {
        "keycloak_url": "http://localhost:8080",
        "keycloak_realm": "master",
        "keycloak_client_id": "ftpserver",
        "keycloak_client_secret": "*****",
        "base_path": "/srv/ftp"
      }
    }
  ]
}

Documentation

Overview

Package keycloak provides a local file system access layer whose users are authenticated by Keycloak

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingBasePath is triggered when the base_path property isn't specified
	ErrMissingBasePath = errors.New("base_path must be specified")

	// ErrLogin is returned when the user couldn't be authenticated by Keycloak
	ErrLogin = errors.New("login failed, User or Password error")

	// ErrMissingKeycloakClientCredentials is returned when the keycloak parameters are incomplete
	ErrMissingKeycloakClientCredentials = errors.New("missing the keycloak client credentials")

	// ErrInvalidUserName is returned when the user name can't be used as a directory name
	ErrInvalidUserName = errors.New("invalid user name")
)

Functions

func LoadFs

func LoadFs(access *confpar.Access) (afero.Fs, error)

LoadFs loads a file system from an access description

Types

type Authenticator added in v0.16.4

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator checks users credentials against a Keycloak server

func (*Authenticator) CheckPasswd added in v0.16.4

func (a *Authenticator) CheckPasswd(user, pass string) (bool, error)

CheckPasswd checks the user's credentials against Keycloak

type KeycloakAuthenticator deprecated

type KeycloakAuthenticator = Authenticator //nolint:revive // kept for backward compatibility

KeycloakAuthenticator is the former name of Authenticator

Deprecated: use Authenticator instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL