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

docs: Common Expression Language (CEL) #509

Merged
merged 5 commits into from
Nov 27, 2024
Merged

docs: Common Expression Language (CEL) #509

merged 5 commits into from
Nov 27, 2024

Conversation

guicassolato
Copy link
Collaborator

No description provided.

Signed-off-by: Guilherme Cassolato <[email protected]>
@guicassolato guicassolato self-assigned this Nov 25, 2024
@guicassolato guicassolato requested a review from a team November 25, 2024 19:21
docs/features.md Outdated
@@ -250,7 +264,7 @@ spec:
authentication:
"pre-validated-jwt":
plain:
selector: context.metadata_context.filter_metadata.envoy\.filters\.http\.jwt_authn|verified_jwt
expression: metadata.filter_metadata.envoy['filters.http.jwt_authn'].verified_jwt
Copy link
Member

Choose a reason for hiding this comment

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

We've seen issues getting to that data in the wasm-shim when directly requesting that from envoy.
But would that even work on the authorino side? There is no way the entire filter chain's metadata is sent over... is it? Did that ever worked?

Also, this should be metadata.filter_metadata['envoy.filters.http.jwt_authn'].verified_jwt

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It works in Authorino.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, this should be metadata.filter_metadata['envoy.filters.http.jwt_authn'].verified_jwt

Nice catch! Fixing it now. Thanks!

docs/features.md Outdated
- selector: auth.identity.anonymous
operator: eq
value: "true"
- predicate: auth.identity.anonymous
Copy link
Member

Choose a reason for hiding this comment

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

So anonymous is always set in auth.identity at this stage? If it isn't this could result in a evaluation error at runtime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. No, it is not always set. In the example, if the other authentication method wins, then there will be no anonymous in auth.identity.

That wasn't a problem before. I guess now our options are:

  1. has(auth.identity.anonymous) && auth.identity.anonymous
  2. authentication: { "jwt": { …, defaults: { anonymous: { expression: "false" } } }, "anonymous": {…} }

Copy link
Member

@alexsnaps alexsnaps Nov 26, 2024

Choose a reason for hiding this comment

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

There also seem to be optional types, but they are not supported in the rust interpreter afaik... I also need to understand these better anyways, but they'd be another option: auth.identity.?anonymous.hasValue() but you always end up with the same pattern... i.e. test for the presence of the field rather than implying that a null value has some special overloaded semantic.

Copy link
Member

Choose a reason for hiding this comment

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

docs/features.md Show resolved Hide resolved
docs/features.md Show resolved Hide resolved
@@ -644,9 +655,9 @@ spec:
json:
properties:
"api-key-ns":
seletor: auth.identity.metadata.namespace
Copy link
Member

Choose a reason for hiding this comment

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

If only we could test these example for correctness 😭

"born":
selector: auth.identity.metadata.creationTimestamp
"age":
expression: int(request.time.seconds) - (timestamp(auth.identity.metadata.creationTimestamp) - timestamp("1970-01-01T00:00:00Z")).getSeconds()
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a note on request.time ?

docs/features.md Outdated
Comment on lines 800 to 803
- predicate: request.path != '/hi'
- predicate: request.path != '/hello'
- predicate: request.path != '/aloha'
- predicate: request.path != '/ciao'
Copy link
Member

Choose a reason for hiding this comment

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

This could also be expressed as !(request.path in ['/hi', '/hello', '/aloha', '/ciao'])

@@ -250,7 +264,7 @@ spec:
authentication:
"pre-validated-jwt":
plain:
selector: context.metadata_context.filter_metadata.envoy\.filters\.http\.jwt_authn|verified_jwt
expression: metadata.filter_metadata['envoy.filters.http.jwt_authn'].verified_jwt
Copy link
Collaborator

Choose a reason for hiding this comment

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

like this, it is much neater and easier to read IMO

Copy link
Member

@alexsnaps alexsnaps left a comment

Choose a reason for hiding this comment

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

🙏

@guicassolato guicassolato merged commit 20d75a5 into main Nov 27, 2024
12 checks passed
@guicassolato guicassolato deleted the docs/cel branch November 27, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants