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

Port register, login and update services to the new ECS style #923

Merged
merged 25 commits into from
Jan 22, 2025

Conversation

LDiazN
Copy link
Contributor

@LDiazN LDiazN commented Jan 17, 2025

This PR is related to #907 and ports services for login, register and update to the new ECS development style, mostly copied and pasted from the monolith, including tests.

No host points to this services right now, so it shouldn't crash any existent probes or infrastructure.

You can try the new endpoints here

@LDiazN LDiazN requested a review from hellais January 17, 2025 15:30
response : Response,
settings : Settings = Depends(get_settings),
) -> ProbeLoginResponse:
global log
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to make the log variable global?

Copy link
Contributor Author

@LDiazN LDiazN Jan 22, 2025

Choose a reason for hiding this comment

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

Not really, I will remove it. I was mixing it with the pattern used in the monolith (example here), but now that I look closer is very different


return register_response

class ProbeUpdate(BaseModel):
Copy link
Member

Choose a reason for hiding this comment

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

The ProbeUpdate request contains some useful metadata that we could use for the purpose of the anonymous credential anomaly detection to establish a baseline for comparing the probe_cc and probe_asn inconsistencies (see: https://github.com/ooni/orchestra/blob/master/registry/registry/handler/registry.go#L25).

Basically what I'm thinking of is that, if we assume that the update requests are not going to be tampered with as much as the measurement submit ones, we can use this to determine which inconsistencies are due to our geoip being off compared to the probe one, vs those which are due to the measurement metadata being inconsistent due to malice.

We can do parsing and logging of this as a follow up PR though.

# "audience" claim. The "issued at" claim is rounded up.
issued_at = int(time.time())
payload = {"iat": issued_at, "aud": "probe_login"}
client_id = create_jwt(payload, key=settings.jwt_encryption_key)
Copy link
Member

Choose a reason for hiding this comment

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

We should take note of the fact the jwt_encryption_key is being shared for between probes and user authenticating via email in the auth service.

I don't think there is necessary a problem, given that the aud field is different, but we should make sure we don't forget to always check aud filed to avoid authentication bypasses.

Copy link
Member

Choose a reason for hiding this comment

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

Following a discussion with @LDiazN we decided to actually change this to a dedicated JWT token which we generate and inject via terraform: https://github.com/ooni/devops/blob/main/tf/environments/dev/main.tf#L187

@hellais
Copy link
Member

hellais commented Jan 21, 2025

This looks good.

Here is a summary of what should be addressed prior to merge:

  • Few nitpick comments (global log and linting)
  • Add comment in the auth component about the jwt token reuse
  • Create follow up issue about recording metadata during update and adding support for metrics collection using prometheus or other metric collector

@LDiazN LDiazN merged commit 7cb00cf into master Jan 22, 2025
7 checks passed
@hellais hellais deleted the luis/ams-probe-services-port branch January 24, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants