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 support for fine-grained websocket filtering #82

Draft
wants to merge 4 commits into
base: master
from

Conversation

@aaslamin
Copy link
Contributor

aaslamin commented Nov 20, 2019

Issue: aporeto-inc/aporeto#1699

ℹ️ This PR is building on-top of API changes to elemental introduced here: aporeto-inc/elemental#61


This PR:

  • ⚠️ Breaking change: add new method to the Session interface, PushConfig, to make it possible to retrieve the push config currently active on the session.

Note: this was done so that this callback:

  1. has enough context to decide whether it is worth parsing the entire identifiable
  2. be able to do fine-grain identity filtering via https://github.com/aporeto-inc/elemental/blob/master/matcher.go#L10
  • 🔥 Remove usage of deprecated type elemental.PushFilter; replaced with the re-named equivalent elemental.PushConfig

  • Parse the identity filters upon receipt of a elemental.PushConfig to avoid having to parse them on each push event received by the push server

    • in the event that parsing fails, the socket is closed.

TODO:

  • test for new session method
  • test for verifying parsing logic on receipt of an elemental.PushConfig from connected client
    • happy path
    • error case where the parsing fails - socket should get closed
edit:
- 💥 add new method to the 'Session' interface, 'PushConfig', to make it possible to retrieve the current push config active on the session.

- 🔥 remove usage of deprecated type 'elemental.PushFilter'; replaced with the re-named equivalent 'elemental.PushConfig'

- parse the identity filters upon receipt of a 'elemental.PushConfig' to avoid having to parse them on each push event received by the push server
    - in the event that parsing fails, the socket is closed.
@aaslamin aaslamin requested review from primalmotion and t00f Nov 20, 2019
@aaslamin

This comment has been minimized.

Copy link
Contributor Author

aaslamin commented Nov 20, 2019

/build - automatically fired by gogo with following PRs and commit SHAs v1.0.0

[
  {
    "project": "websocket-filtering",
    "component": "elemental",
    "pr-id": "61",
    "commit-sha": "fe1cdd68fa5787ec71e7a33771ecd34bcefe2c7d"
  },
  {
    "project": "websocket-filtering",
    "component": "bahamut",
    "pr-id": "82",
    "commit-sha": "8973cff17ff60c1940fa600393b557811878b43a"
  }
]
@t00f

This comment has been minimized.

Copy link
Member

t00f commented Nov 20, 2019

/build - automatically fired by gogo with following PRs and commit SHAs v1.0.0

[
  {
    "project": "websocket-filtering",
    "component": "bahamut",
    "pr-id": "82",
    "commit-sha": "8973cff17ff60c1940fa600393b557811878b43a"
  },
  {
    "project": "websocket-filtering",
    "component": "elemental",
    "pr-id": "61",
    "commit-sha": "fe1cdd68fa5787ec71e7a33771ecd34bcefe2c7d"
  }
]
@aaslamin aaslamin changed the title add support for fine-grained websocket filtering Add support for fine-grained websocket filtering Nov 20, 2019
@aaslamin

This comment has been minimized.

Copy link
Contributor Author

aaslamin commented Nov 28, 2019

Update

  • Added ability for the 'ShouldDispatch' callee to close the socket based on the error type it returns.

If ShouldDispatch returns an error type that has the method ShouldCloseSocket() (bool, int) then it can inform whether the socket should be closed along with a code to use in the close message. This is useful in cases where it makes no sense to continue serving the client (e.g. the client configured a semantically invalid push config, for example: they used a comparator that is not yet supported/implemented).

FYI: @primalmotion

…socket should be closed based on the error type it returns
@aaslamin aaslamin force-pushed the support-socket-identity-filtering branch from aa8254e to 26fda9e Nov 28, 2019
@aaslamin

This comment has been minimized.

Copy link
Contributor Author

aaslamin commented Nov 28, 2019

/build - automatically fired by gogo with following PRs and commit SHAs v1.0.0

[
  {
    "project": "websocket-filtering",
    "component": "elemental",
    "pr-id": "61",
    "commit-sha": "a1aa1431ac568f5a19c9793f9226696291b4a108"
  },
  {
    "project": "websocket-filtering",
    "component": "bahamut",
    "pr-id": "82",
    "commit-sha": "26fda9ee660a1039b385e811ff7cdf4b18b37d90"
  },
  {
    "project": "websocket-filtering",
    "component": "backend",
    "pr-id": "639",
    "commit-sha": "7a8e3502b96300b6f3d982622fa49b102b3e8c99"
  }
]
@aaslamin

This comment has been minimized.

Copy link
Contributor Author

aaslamin commented Nov 28, 2019

/build - automatically fired by gogo with following PRs and commit SHAs v1.0.0

[
  {
    "project": "websocket-filtering",
    "component": "elemental",
    "pr-id": "61",
    "commit-sha": "8f033610ca1b9e881c44f6420f3d7a45a74d2a86"
  },
  {
    "project": "websocket-filtering",
    "component": "bahamut",
    "pr-id": "82",
    "commit-sha": "26fda9ee660a1039b385e811ff7cdf4b18b37d90"
  },
  {
    "project": "websocket-filtering",
    "component": "backend",
    "pr-id": "639",
    "commit-sha": "7a8e3502b96300b6f3d982622fa49b102b3e8c99"
  }
]
@aaslamin

This comment has been minimized.

Copy link
Contributor Author

aaslamin commented Nov 28, 2019

/build - automatically fired by gogo with following PRs and commit SHAs v1.0.0

[
  {
    "project": "websocket-filtering",
    "component": "elemental",
    "pr-id": "61",
    "commit-sha": "8f033610ca1b9e881c44f6420f3d7a45a74d2a86"
  },
  {
    "project": "websocket-filtering",
    "component": "bahamut",
    "pr-id": "82",
    "commit-sha": "26fda9ee660a1039b385e811ff7cdf4b18b37d90"
  },
  {
    "project": "websocket-filtering",
    "component": "backend",
    "pr-id": "639",
    "commit-sha": "2499382adb60ae51cbf64ee78e9c9caf1e961519"
  }
]
websocket_server.go Show resolved Hide resolved
websocket_server.go Outdated Show resolved Hide resolved
websocket_server.go Outdated Show resolved Hide resolved
aaslamin added 2 commits Dec 2, 2019
…pe for when the ShouldDispatch callback would like to close the socket
@aaslamin aaslamin requested a review from primalmotion Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.