-
Notifications
You must be signed in to change notification settings - Fork 22
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
Duplicate auth id fix #1186
Open
hilpitome
wants to merge
27
commits into
v2.1
Choose a base branch
from
duplicate-auth-id-fix
base: v2.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Duplicate auth id fix #1186
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5de2595
add redis test container
bennsimon f05f49f
overide JdbcTokenStore storeAcessToken mthd
hilpitome 111a29b
use reflection to access private fields
hilpitome 0853933
refactor code
hilpitome bea4049
apply openMRS formatter
hilpitome 0cf4fa4
use bean in OAuth2SecurityConfig
hilpitome a0a528b
update version and add logging
hilpitome 5dc1f4e
Update pom.xml
hilpitome e6cde50
refactor storeaAccessToken method
hilpitome 02feef0
Merge branch 'duplicate-auth-id-fix' of github.com:opensrp/opensrp-se…
hilpitome 690124e
Update pom.xml
hilpitome 953575a
add extra logging
hilpitome de19219
Merge branch 'duplicate-auth-id-fix' of github.com:opensrp/opensrp-se…
hilpitome 3dcb9ca
update pom version
hilpitome dbdbf4f
apply formatter;
hilpitome d24820f
log when entering storAccessToken mthd
hilpitome fba0d5d
init unit test for jdbctokenstore
hilpitome a2bf76b
create OAuth2Request instance for testing
hilpitome bf86f64
mock connection;
hilpitome e7a5c42
add env with annotations
hilpitome 8334adc
enable redis
hilpitome eeb57f7
add password to TestRedisConfig
hilpitome 638662d
init use real objects instead of mocks
hilpitome 920f743
delete OAth2SecurityTest and update server version
hilpitome ccd6ecd
retrigger checks
hilpitome 84009bb
merge with branck add-redis-test-container
hilpitome 4ed7f57
revert test postgres settings
hilpitome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
*/ | ||
package org.opensrp.web.config.security; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensrp.web.config.Role; | ||
import org.opensrp.web.security.OauthAuthenticationProvider; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
@@ -89,12 +91,17 @@ public DefaultTokenServices tokenServices() { | |
public JdbcTokenStore tokenStore() { | ||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | ||
final AuthenticationKeyGenerator authenticationKeyGenerator = new DefaultAuthenticationKeyGenerator(); | ||
Logger logger = LogManager.getLogger(JdbcTokenStore.class.toString()); | ||
return new JdbcTokenStore(dataSource) { | ||
|
||
@Override | ||
public void storeAccessToken(final OAuth2AccessToken token, final OAuth2Authentication authentication) { | ||
final String key = authenticationKeyGenerator.extractKey(authentication); | ||
jdbcTemplate.update("delete from oauth_access_token where authentication_id = ?", key); | ||
if( key == null || authentication == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super needs to be called since it is mostly operating on the |
||
return; | ||
int rowsAffected = jdbcTemplate.update("delete from oauth_access_token where authentication_id = ?", key); | ||
String isSuccess = ( rowsAffected > 0 ) ? "Success" : "Failure"; | ||
logger.info("Attempt to delete authentication_id {} from oauth_access_token table was a {}", key, isSuccess); | ||
super.storeAccessToken(token, authentication); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for null
authentication
.