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

feat(jans-client-api): Use injectable operations and remove serviceprovider #1643

Conversation

jmunozherbas
Copy link
Contributor

@jmunozherbas jmunozherbas commented Jun 30, 2022

Prepare


Description

use injectable operations and remove ServiceProvider class

Target issue

#1532

Implementation Details

Refactoring code
Operations are injected directly in request


Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

@mo-auto mo-auto added comp-jans-client-api Component affected by issue or PR kind-feature Issue or PR is a new feature request labels Jun 30, 2022
@jmunozherbas jmunozherbas reopened this Jun 30, 2022
@jmunozherbas jmunozherbas marked this pull request as ready for review June 30, 2022 06:00
@sonarcloud
Copy link

sonarcloud bot commented Jun 30, 2022

[jans-client-api] SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
3.1% 3.1% Duplication

Copy link
Contributor

@yuriyz yuriyz left a comment

Choose a reason for hiding this comment

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

Lets keep authorization check in Filter.

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

[jans-pycloudlib] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

[notify] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

[orm] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

[jans-core] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@jmunozherbas jmunozherbas requested a review from yuriyz July 8, 2022 14:54
log.info("\n\n\n AuthorizationFilter::filter() - authorizationHeader = " + authorizationHeader + " , authorizationRpIdHeader = "
+ authorizationRpIdHeader + " \n\n\n");
try {
authorizationService.processAuthorization(info.getPath(), context.getMethod(), request.getRemoteAddr(), authorizationHeader, authorizationRpIdHeader);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have filter which performs authorization why do we still authorize again here io.jans.ca.server.op.BaseOperation#getObjectForJsonConversion ?

 if (getCommandType().isAuthorizationRequired()) {
            final ApiAppConfiguration conf = jansConfigurationService.find();
            String authorization = httpRequest.getHeader("Authorization");
            String authorizationRpId = httpRequest.getHeader("AuthorizationRpId");
            validateAccessToken(authorization, safeToRpId((HasRpIdParams) params, authorizationRpId), conf);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case AuthorizationRpId header is null, then it is read from body params:

validateAccessToken(authorization, safeToRpId((HasRpIdParams) params, authorizationRpId), conf);

I tried to read the body content in filter, but then the body is not available for io.jans.ca.server.op.BaseOperation#process method.

io.jans.ca.server.filter.AuthorizationFilter process the token validation only when AuthorizationRpId header is not null.

One option could be to establish AuthorizationRpId header as mandatory.
Otherwise, we can look for a way to read body in filter, without losing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, lets read authorizationRpId from header and move it out of body. In general everything was in body because oxd was designed as backchannel app, we should re-think it since now it's web app.

Copy link
Contributor Author

@jmunozherbas jmunozherbas Jul 13, 2022

Choose a reason for hiding this comment

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

Now, authorizationRpId is mandatory in header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is ready for review

}

@Override
public CommandType getCommandType() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since now it's injectable operation we don't need commandType because we should not have central processing. Isn't it? Remove CommandType and all info should go to operation (e.g. return type).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I will remove.

@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2022

[jans-cli] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@jmunozherbas jmunozherbas requested a review from yuriyz July 13, 2022 05:02
@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2022

[jans-config-api-parent] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2022

[jans-linux-setup] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2022

[Jans authentication server parent] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@yuriyz yuriyz merged commit 982cab3 into main Jul 15, 2022
@yuriyz yuriyz deleted the feat-jans-client-api-use-injectable-operations-and-remove-serviceprovider branch July 15, 2022 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-jans-client-api Component affected by issue or PR kind-feature Issue or PR is a new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants