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

Add Basic Auth Traffic Policy Example #609

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nijikokun
Copy link
Collaborator

@nijikokun nijikokun commented Feb 22, 2024

Adds Basic Auth enforcement example to the Rule Gallery. This rule mimics the Basic Auth module.

# Block all requests without Authorization Header
# Block all requests without valid username:password base64 encodings
inbound:
  - expressions:
      - |-
        !('Authorization' in req.Headers) ||
        !(
          'Basic dXNlcm5hbWU6cGFzc3dvcmQ=' in req.Headers['Authorization'] || 
          'Basic dXNlcm5hbWU6aHVudGVyMg==' in req.Headers['Authorization'] || 
          'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' in req.Headers['Authorization']
        )
    actions:
      - type: custom-response
        config:
          status_code: 401
          content: 'Authorization required.'
          headers:
            'WWW-Authenticate': 'Basic realm="MySite", charset="UTF-8"'

@nijikokun nijikokun added the documentation Improvements or additions to documentation label Feb 22, 2024
Copy link

vercel bot commented Feb 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ngrok-docs ✅ Ready (Inspect) Visit Preview Feb 22, 2024 2:20am

Copy link
Contributor

@euank euank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding another example!

This does make my security sense tingle though! It's clear it's being stored and used unhashed, so if I saw this on a technical company's websites, I'd lose some amount of trust in their security unless it also had a prominent warning of that fact, so as such, I think we should have a prominent security warning until we have a way to input pre-hashed psaswords.

docs/http/traffic-policy/gallery.mdx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants