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 additional options for service auth #25

Merged
merged 12 commits into from
May 2, 2024

Conversation

ajermaky
Copy link
Contributor

💸 TL;DR

Adding additional options for service auth

🧪 Testing Steps / Validation

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

Copy link

@kylelemons kylelemons left a comment

Choose a reason for hiding this comment

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

In general, baseplate.go v0 is not really getting new features, which are preferentially being built into the baseplate.go v2 ecosystem.

Do you know what services need this? Are they using baseplate.go v0? Can they adopt v2?

Either way, I think an implementation in v2 will be required, regardless of whether one is integrated into v0.

Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

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

agree with kyle that we also need to add this to v2, but the v0 part lgtm mostly.

if s.isService() {
token := AuthenticationToken(s)
if token.OnBehalfOf == nil {
return
Copy link
Member

Choose a reason for hiding this comment

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

the original go code was written long time ago that we have slightly different style guidance now, we prefer not to use naked returns and always return explicitly:

Suggested change
return
return "", false

same for the rest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense! i'll update the new code to follow that style

@ajermaky
Copy link
Contributor Author

ajermaky commented May 1, 2024

For context we did add this implementation in v2, this is mainly backporting this so folks using the python libraries will have access to these new fields

Copy link

@kylelemons kylelemons left a comment

Choose a reason for hiding this comment

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

(for Go, let a real python person approve that part)

lib/go/edgecontext/edgecontext_test.go Outdated Show resolved Hide resolved
lib/go/edgecontext/edgecontext_test.go Outdated Show resolved Hide resolved
lib/go/edgecontext/edgecontext_test.go Outdated Show resolved Hide resolved
lib/go/edgecontext/service.go Outdated Show resolved Hide resolved
@kylelemons kylelemons requested a review from chriskuehl May 1, 2024 19:38
Comment on lines +143 to +146
self.assertEqual(token.subject, "service/test-service")
self.assertEqual(token.on_behalf_of_roles, ["admin"])
self.assertEqual(token.on_behalf_of_id, "t2_deadbeef")
self.assertEqual(token.requests_elevated_access, True)
Copy link
Member

Choose a reason for hiding this comment

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

🔕 since these tests run with pytest, I would probably recommend using regular assertion statements (e.g. assert token.subject == "service/test_service"). pytest will do its magic assertion rewriting to produce a better error output than the TestCase assert mehtods.

Not necessary to change though, I know you're following the pre-existing pattern in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense - i can at least update the new changes to follow the new style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

take it back - looks like the linters were complaining so going to keep it as is - if we want to update the linters in drone, will defer that into a separate change

@ajermaky ajermaky merged commit 496f7dd into develop May 2, 2024
4 checks passed
@ajermaky ajermaky deleted the add_additional_options_for_service_auth branch May 2, 2024 15:48
@ajermaky ajermaky mentioned this pull request Jul 3, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants