Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caddyauth: Add realm support to basicauth Caddyfile directive #3315

Merged
merged 1 commit into from
May 18, 2020

Conversation

francislavoie
Copy link
Member

Closes #3252

Old syntax:

basicauth [<matcher>] [<hash_algorithm>]

New syntax:

basicauth [<matcher>] [<hash_algorithm> [<realm>]]

Caddyfile example:

:80

basicauth /protected* bcrypt restricted {
    Bob JDJhJDEwJEVCNmdaNEg2Ti5iejRMYkF3MFZhZ3VtV3E1SzBWZEZ5Q3VWc0tzOEJwZE9TaFlZdEVkZDhX
}

Adapted JSON:

{
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":80"
          ],
          "routes": [
            {
              "match": [
                {
                  "path": [
                    "/protected*"
                  ]
                }
              ],
              "handle": [
                {
                  "handler": "authentication",
                  "providers": {
                    "http_basic": {
                      "accounts": [
                        {
                          "password": "JDJhJDEwJEVCNmdaNEg2Ti5iejRMYkF3MFZhZ3VtV3E1SzBWZEZ5Q3VWc0tzOEJwZE9TaFlZdEVkZDhX",
                          "username": "Bob"
                        }
                      ],
                      "hash": {
                        "algorithm": "bcrypt"
                      },
                      "realm": "restricted"
                    }
                  }
                }
              ]
            }
          ]
        }
      }
    }
  }
}

@francislavoie francislavoie added this to the 2.1 milestone Apr 26, 2020
@francislavoie francislavoie requested a review from mholt April 26, 2020 23:14
@mholt mholt added the under review 🧐 Review is pending before merging label Apr 27, 2020
@Komin123
Copy link

#3252

@mholt mholt merged commit 41a682d into caddyserver:master May 18, 2020
@mholt mholt removed the under review 🧐 Review is pending before merging label May 18, 2020
@francislavoie francislavoie deleted the basicauth-realm-caddyfile branch May 18, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add realm parameter to basicauth directive for Caddyfile
3 participants