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 hybrid flow migration issue #2575

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Thumimku
Copy link
Contributor

@Thumimku Thumimku commented Sep 22, 2024

Issue

Issue : wso2/product-is#21140

Proposed fix

Before the fix wso2/product-is#20331, applications don't have hybrid flow enabled properties, hence according to the logic hybrid flow is disabled which causes the Backward Incompatibility.

Now with added new fix, if the property is missing which means the application doesn't have hybridFlowEnabled property(probably an application created before the fix), hence providing the previous behaviour, which is enabling the hybrid flow with all allowed response types.

Debug Log:

[2024-09-23 00:35:00,092] [03c5c187-bac3-44c3-8539-0146f38ac019]  DEBUG {org.wso2.carbon.identity.oauth.dao.OAuthAppDAO} - This application with consumer key 70_x1i8nTwzO7qvf82CNdhZvnrEa doesn't have hybridFlowEnabled property, hence providing the previous behaviour, which is enabling the hybrid flow with all allowed response types.
  • Unit test for Creation
  • Unit test for Migrated App

Tested Scenarios

  • Migrated App

    • Try code token, code id_token, code id_token token response types and get expected results.
    • Disable Hybrid flow - working as expected.
    • Try Hybrid flow after disabling the feature - working as expected.
    • Try Hybrid flow after disabling the server config feature .
  • New App

    • Try code token, code id_token, code id_token token response types after configuring a selected response type and get expected results. - only configured response type will get successful response.
    • Disable Hybrid flow - working as expected.
    • Try Hybrid flow after disabling the feature - working as expected.
  • Working with Server Configuration for existing apps

We have a sever wide config to enable/disable specific response types. current application configuration logic won't support this server wide config (If some disable a response type in server config, he/she still can configure it via UI). This logic partially fix this issue.

  • If all hybrid flow response types are disabled, then application hybrid flow configuration also disabled.
  • If one hybrid flow response types is enabled, then application hybrid flow configuration is enabled and configured response type will be set on application retrieval.
  • If more than one hybrid flow response types are enabled, then application hybrid flow configuration is enabled and configured response type will be "code id_token token". Currently DAO allows to have one string for configured hybrid flow response types so I went for this option to preserve the backward compatibility. But we need to fix it in seperate effort.

UI

Following is the UI for the migrated app regarding hybrid flow.

Screenshot 2024-09-23 at 12 32 25

UI when the hybrid flow is disabled via server config.

Screenshot 2024-09-24 at 12 04 22

UI when only code id_token is enabled via server config. (code token and code id_token token is disabeld)
Screenshot 2024-09-24 at 12 07 29

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/10983691062

Copy link

codecov bot commented Sep 22, 2024

Codecov Report

Attention: Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.

Project coverage is 37.74%. Comparing base (f49ad8a) to head (c1267b9).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
...rg/wso2/carbon/identity/oauth/dao/OAuthAppDAO.java 41.66% 6 Missing and 1 partial ⚠️
...dentity/oauth/config/OAuthServerConfiguration.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2575      +/-   ##
============================================
- Coverage     37.78%   37.74%   -0.05%     
+ Complexity     5321     5298      -23     
============================================
  Files           584      584              
  Lines         44529    44416     -113     
  Branches       6538     6529       -9     
============================================
- Hits          16827    16763      -64     
+ Misses        25351    25310      -41     
+ Partials       2351     2343       -8     
Flag Coverage Δ
unit 37.74% <47.05%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/10983691062
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/10983691062

@Thumimku
Copy link
Contributor Author

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 37.79%. Comparing base (f49ad8a) to head (aed7f7f).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...rg/wso2/carbon/identity/oauth/dao/OAuthAppDAO.java 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files

@@            Coverage Diff            @@
##             master    #2575   +/-   ##
=========================================
  Coverage     37.78%   37.79%           
- Complexity     5321     5322    +1     
=========================================
  Files           584      584           
  Lines         44529    44536    +7     
  Branches       6538     6540    +2     
=========================================
+ Hits          16827    16831    +4     
- Misses        25351    25353    +2     
- Partials       2351     2352    +1     

☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.

Missing lines are due to dubeg logs, it seems debug log level is not activating have to fix with seperate effort.

shashimalcse
shashimalcse previously approved these changes Sep 23, 2024
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/11008003195

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/11008003195
Status: failure

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/11011711257

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/11011711257
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/11011711257

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/11208280017

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/11208280017
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/11208280017

{true, "code token", true, "code token"},
{false, "code id_token", false, "code id_token"},
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line

oauthApp.setHybridFlowEnabled(true);
oauthApp.setHybridFlowResponseType(configuredHybridResponseTypes.get(0));
break;
default:
Copy link
Contributor

@asha15 asha15 Oct 8, 2024

Choose a reason for hiding this comment

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

Here when the user assigned two hybrid flow response types, it will enable all the hybrid flow responses. IMO it's incorrect, we need to improve it.

If this will be reevaluated with a separate effort, +1 to proceed with the current approach.

Comment on lines +820 to +823
mockStatic(OAuthComponentServiceHolder.class)) {
setupMocksForTest(oAuthServerConfiguration, identityTenantUtil, identityUtil);
mockUserstore(oAuthComponentServiceHolder);
try (Connection connection = getConnection(DB_NAME)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the alignment

createDeleteQuery(CONSUMER_KEY, "hybridFlowEnabled");
final String deleteHybridFlowResponseTypeProperty =
createDeleteQuery(CONSUMER_KEY, "hybridFlowResponseType");

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the additional line.

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.

Support Application level configuration to allow response type in OIDC Hybrid flow
4 participants