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

Attribute based access controll support #499

Merged
merged 29 commits into from
May 19, 2021
Merged

Conversation

jakesmolka
Copy link
Contributor

@jakesmolka jakesmolka commented May 5, 2021

Changes

  • Adds ABAC integration support
  • Adds integration tests (needs fresh DB and are disabled by default)

A lot of configuration possible. See application.yml for information.

For a meta-perspective see AbacIntegrationTest.java.

For the implementation itself the CustomMethodSecurityExpressionRoot.

The whole feature is rather huge and complex, so see https://wiki.vitagroup.ag/display/ETHERCIS/ABAC+Integration for a better overview.

Related issue

closes https://github.com/ehrbase/project_management/issues/505

Additional information and checks

  • Pull request linked in changelog
  • Create separate issue to add the ABAC tests to the CI pipeline
  • Push documentation to public readthedocs documentation (the documentation will just be added into the current structure, see https://github.com/ehrbase/project_management/issues/521)

@subigre subigre self-requested a review May 7, 2021 07:36
.POST(BodyPublishers.ofString(requestBody))
.build();

return HttpClient.newHttpClient().send(request, BodyHandlers.ofString());
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not directly linked to this task but as a potential (future?) improvement, I would suggest to that we could reuse the HttpClient instance configured through ClientConfiguration and ClientProperties.
I do not know i EHRbase requires other external accesses than ABAC server and remote terminology servers?
It could be nice to have common configurations for all HTTP clients. For instance, if EHRbase running behind an authenticated proxy or if an ABAC instance also requires two-way authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the foundation for this in the last commit. I does only allow to set a proxy yet, because I'm not sure how real auth requirements would look like. Can you recheck this too, and check if this is the direction you had in mind?

@@ -30,6 +30,7 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Copy link
Contributor

Choose a reason for hiding this comment

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

For the readability and maintenance, I think that we should create separate configuration classes like : SecurityConfiguration, BasicSecurityConfigucation, OAuth2SecurityConfiguration
And we could enable the correct one using @ConditionalOnProperty annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I refactored the config classes to be separated like you suggest. Can you check again if that looks okay?

Copy link
Contributor

@subigre subigre left a comment

Choose a reason for hiding this comment

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

Please find my comments. There are mostly improvements and "cosmetic" changes

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@ConditionalOnProperty(name = "abac.enabled")
Copy link
Contributor

@subigre subigre May 11, 2021

Choose a reason for hiding this comment

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

I think it is better to create the @bean in AbacConfig class in that specific case. I would say that @Component should be used for beans that are always created.
It is my own opinion and probably a personal preference .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I refactored it.

@Configuration
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "httpclient")
public class HttpClientConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh interesting, didn't knew it was there. I'm not sure now. Why is yours in the service package? In the end two different http client config are obviously not a good practice. But it feels wrong to pull that client from the service layer into my ABAC stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there was no activity for 7 days I extracted that into the following issue, so I can continue with this PR here.
https://github.com/ehrbase/project_management/issues/522

Copy link
Contributor

@subigre subigre left a comment

Choose a reason for hiding this comment

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

Looks good but I added two comments

@sonarcloud
Copy link

sonarcloud bot commented May 19, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

12.1% 12.1% Coverage
1.7% 1.7% Duplication

@jakesmolka jakesmolka merged commit ca3815c into develop May 19, 2021
@jakesmolka jakesmolka deleted the feature/505_abac branch May 19, 2021 12:26
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.

None yet

2 participants