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

Fix: set user on transaction #1443

Merged
merged 9 commits into from
Apr 28, 2021
Merged

Fix: set user on transaction #1443

merged 9 commits into from
Apr 28, 2021

Conversation

maciejwalkowiak
Copy link
Contributor

📜 Description

Set user on transaction.

User is set on the scope in Servlet filter - SentryUserFilter. This filter must run after Spring security (or any other filter verifying authentication details) so that SentryUserProvider implementations can access the currently logged in user data.

Sentry request flow

In Spring Boot integration, SentryUserFilter is set to run:

  • by default runs as the last filter (lowest precedence)
  • user can explicitly define the order

In Spring integration, filter bean must be created manually and a corresponding DelegatingFilterProxy servlet filter must be registered.

💡 Motivation and Context

Fixes #1335

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2021

Codecov Report

Merging #1443 (376a316) into main (a33afef) will decrease coverage by 0.01%.
The diff coverage is 70.83%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1443      +/-   ##
============================================
- Coverage     75.88%   75.87%   -0.02%     
- Complexity     1889     1901      +12     
============================================
  Files           187      189       +2     
  Lines          6453     6499      +46     
  Branches        633      640       +7     
============================================
+ Hits           4897     4931      +34     
- Misses         1261     1272      +11     
- Partials        295      296       +1     
Impacted Files Coverage Δ Complexity Δ
.../io/sentry/spring/SentryInitBeanPostProcessor.java 97.22% <ø> (ø) 6.00 <0.00> (ø)
...entry/spring/SentryUserProviderEventProcessor.java 96.55% <ø> (ø) 12.00 <0.00> (ø)
...entry/spring/SpringSecuritySentryUserProvider.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...n/java/io/sentry/spring/boot/SentryProperties.java 76.66% <33.33%> (-4.82%) 9.00 <1.00> (+1.00) ⬇️
...c/main/java/io/sentry/spring/SentryUserFilter.java 92.85% <92.85%> (ø) 10.00 <10.00> (?)
...io/sentry/spring/boot/SentryAutoConfiguration.java 98.18% <100.00%> (+0.18%) 1.00 <0.00> (ø)
.../io/sentry/spring/tracing/SentryTracingFilter.java 81.57% <0.00%> (+5.26%) 7.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a33afef...376a316. Read the comment docs.

@@ -54,6 +54,12 @@ public class io/sentry/spring/SentrySpringServletContainerInitializer : javax/se
public fun onStartup (Ljava/util/Set;Ljavax/servlet/ServletContext;)V
}

public class io/sentry/spring/SentryUserFilter : javax/servlet/Filter {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we need to add these to the docs and a note on a migration plan for the next version (should be 5.0 I believe)?

@marandaneto
Copy link
Contributor

marandaneto commented Apr 28, 2021

@maciejwalkowiak we need docs for this
getsentry/sentry-docs#3482

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

LGTM

@marandaneto marandaneto merged commit dd652c2 into main Apr 28, 2021
@marandaneto marandaneto deleted the gh-1335-3 branch April 28, 2021 11:19
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.

User is not set on transactions
4 participants