Skip to content

make auth more robust, if not email key#303

Merged
peterdudfield merged 2 commits intomainfrom
bug/claims
Apr 29, 2026
Merged

make auth more robust, if not email key#303
peterdudfield merged 2 commits intomainfrom
bug/claims

Conversation

@peterdudfield
Copy link
Copy Markdown
Contributor

Pull Request

Description

Fix if the authentication has no email key. This can happen if auth is done via secret id and key.

Helps with https://github.com/openclimatefix/client-private/issues/418

How Has This Been Tested?

  • CI tests

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@peterdudfield peterdudfield requested a review from braddf April 29, 2026 11:02
# set the apitally consumer, this means we can see who has used which routes
email = claims["https://openclimatefix.org/email"]
set_consumer(request,identifier=email)
if EMAIL_KEY in claims:
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.

What is EMAIL_KEY / where does it get set..?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its "https://openclimatefix.org/email" and just set at the top of this file

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.

Righhht okay, we just weren't using it before, got it

Copy link
Copy Markdown
Contributor

@braddf braddf left a comment

Choose a reason for hiding this comment

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

Would be good to be able to tell if we are connecting ourselves using client_id/client_secret, but at least this will stop the errors 👍

# set the apitally consumer, this means we can see who has used which routes
email = claims["https://openclimatefix.org/email"]
set_consumer(request,identifier=email)
if EMAIL_KEY in claims:
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.

Righhht okay, we just weren't using it before, got it

@peterdudfield
Copy link
Copy Markdown
Contributor Author

Would be good to be able to tell if we are connecting ourselves using client_id/client_secret, but at least this will stop the errors 👍

I could add a log warning? If you think that would be useful

@peterdudfield
Copy link
Copy Markdown
Contributor Author

Would be good to be able to tell if we are connecting ourselves using client_id/client_secret, but at least this will stop the errors 👍

I could add a log warning? If you think that would be useful

I slipped this in so we can see whats happen

@peterdudfield peterdudfield merged commit bbb9b13 into main Apr 29, 2026
8 checks passed
@peterdudfield peterdudfield deleted the bug/claims branch April 29, 2026 13:53
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