Skip to content

Htpasswd authorization

Authorizes a user request via credentials stored in htpasswd format.

Properties

type

Authorization Type = "htpasswd"

Has to be set to htpasswd to enable the htpasswd authorization.

rememberMe

RememberMe = "forbidden"

Controls saved browser and SSH access.

remoteName

string Authorization Request = "{{.remote.user}}"

Name used for case-sensitive lookup in the htpasswd file or inline entries. The original requesting name remains unchanged in flow requirements and audit records; see the example.

file

File Path = "<os specific>"

A file where each line contains an entry in htpasswd format.

The default value varies depending on the platform Bifröst runs on:

  • Linux: /etc/engity/bifroest/htpasswd
  • Darwin: /Library/Application Support/Engity/Bifroest/htpasswd
  • Windows: C:\ProgramData\Engity\Bifroest\htpasswd

Examples

/etc/engity/bifroest/htpasswd
1
2
foo:$apr1$zapgfl56$eXIHR/wBYFypkUEXWdCZN/
bar:$apr1$wqkvo7c2$dqi5g.hK67jLMY4SJzrjq.

entries

string

This is similar to file, but does contain the htpasswd entries directly inside the configuration.

Examples

1
2
3
4
5
6
authorization:
  type: htpasswd
  rememberMe: allowedAndEnabledByDefault
  entries: |
    foo:$apr1$zapgfl56$eXIHR/wBYFypkUEXWdCZN/
    bar:$apr1$wqkvo7c2$dqi5g.hK67jLMY4SJzrjq.

Format

htpasswd is a format created for Apache HTTP Server to enable an easy way to configure Basic Authentication for web servers. Nowadays, it is used in more web server projects than just the Apache HTTP Server and also in other project types like Bifröst. The reason: There is a huge toolset available to create those files.

Tools

  1. Apache HTTP Server command line tool which can be easily installed on many systems such as:
    • Ubuntu:
      1
      sudo apt-get install apache2-utils -y
      
    • Fedora/RedHat:
      1
      sudo apt install apache2-utils -y
      
  2. Helm for Kubernetes function
  3. Ansible module
  4. Terraform/OpenTofu plugin
  5. ...

Context

This authorization will produce a context of type Authorization Htpasswd.

Examples

  1. Using dedicated file from default location:
    1
    2
    type: htpasswd
    rememberMe: allowedAndEnabledByDefault
    
  2. Using dedicated file from custom location:
    1
    2
    3
    type: htpasswd
    rememberMe: allowedAndEnabledByDefault
    file: /etc/foo/bar
    
  3. Using embedded entries:
    1
    2
    3
    4
    5
    type: htpasswd
    rememberMe: allowedAndEnabledByDefault
    entries: |
      foo:$apr1$zapgfl56$eXIHR/wBYFypkUEXWdCZN/
      bar:$apr1$wqkvo7c2$dqi5g.hK67jLMY4SJzrjq.
    

Login name with an SSH suffix

Authenticate SSH login foo@bar against htpasswd entry foo, while keeping HTTP login names unchanged:

1
2
3
4
5
6
7
8
9
type: htpasswd
rememberMe: allowedAndEnabledByDefault
file: /etc/engity/bifroest/htpasswd
remoteName: >
  {{- if eq .connection.transport "ssh" -}}
    {{- regexReplaceAll "@[^@]+$" .remote.user "" -}}
  {{- else -}}
    {{- .remote.user -}}
  {{- end -}}

Flow requirements still match the original name: use requirement.ssh.includedRequestingName: '@bar$' for this suffix and, for example, requirement.http.includedSlug: '^docker$' for the browser link. Connect with ssh -l 'foo@bar' bifroest.example.org, or open /#docker and enter foo. Sharing credentials across flows does not merge their sessions.

Compatibility

linux darwin windows
/ / /