Skip to content

Introduce a templating system to base64 encode variables#352

Merged
Taiki-San merged 11 commits into
mainfrom
emilehugo.spir/basic-auth
Apr 29, 2026
Merged

Introduce a templating system to base64 encode variables#352
Taiki-San merged 11 commits into
mainfrom
emilehugo.spir/basic-auth

Conversation

@Taiki-San

@Taiki-San Taiki-San commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

This PR introduce support for a syntax enabling base64 encoding parts of a request. This is helpful to support Basic Auth which involved base64 encoding the username and password to authenticate the request.
The syntax look like %base64(arbitrary_string). Variables can be used in the transformation (%base64($MATCH)) but can't contain transformation instruction ($MATCH => %base64(bla) will be escaped and rendered literally).
The engine ignore unknown instructions (for instance, URL encoded strings)

@Taiki-San
Taiki-San requested a review from a team as a code owner April 24, 2026 11:27

@isabella-garza-datadog isabella-garza-datadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of denoting the encoding in the key name, I noticed there's already a comment in config_v2.rs (link) that suggests using an inline function syntax in the value instead:

/// Example: {"Authorization": "Basic %base64($CLIENT_ID:$MATCH)"}

I think that reads a bit more naturally since the transformation is right where the encoding happens and we don't need to strip the suffix from the key name. What do you think about using that approach instead?

@Taiki-San

Copy link
Copy Markdown
Contributor Author

The syntax that's documented here would definitely be better!
Back when we implemented the initial RFC, we assumed that this would be complex to implement. I didn't want to relitigate this again, and just unlock Basic Auth. If it's cool with you, I can send you a proposal of the more generic variant

@Taiki-San Taiki-San changed the title Introduce a workaround to support Basic Auth Introduce a templating system to base64 encode variables Apr 28, 2026

@isabella-garza-datadog isabella-garza-datadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for making the changes and the exhaustive tests! Just left a few small suggestions

Comment thread sds/src/match_validation/config_v2.rs Outdated
Comment thread sds/src/match_validation/config_v2.rs Outdated
Comment thread sds/src/match_validation/config_v2.rs Outdated

@isabella-garza-datadog isabella-garza-datadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall! Left one last small comment 😸

Comment thread sds/src/match_validation/config_v2.rs
@Taiki-San
Taiki-San merged commit f146576 into main Apr 29, 2026
4 checks passed
@Taiki-San
Taiki-San deleted the emilehugo.spir/basic-auth branch April 29, 2026 12:42
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.

2 participants