Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@paulineribeyre
Copy link
Contributor

@paulineribeyre paulineribeyre commented Aug 1, 2025

Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/MIDRC-1071
Closes #1149

user registration before-after

New Features

  • The user registration flow has been modified in order to enforce registration before a user is officially logged in and can access website pages and data (when user registration is enabled)

Breaking Changes

Bug Fixes

Improvements

Dependency updates

Deployment changes

@coveralls
Copy link

coveralls commented Aug 1, 2025

Pull Request Test Coverage Report for Build 17286237580

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 183 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.2%) to 74.91%

Files with Coverage Reduction New Missed Lines %
blueprints/admin.py 3 67.19%
blueprints/login/shib.py 3 94.0%
blueprints/login/fence_login.py 8 81.03%
init.py 9 89.96%
resources/user/user_session.py 11 86.59%
auth.py 14 88.14%
blueprints/login/base.py 27 79.33%
resources/user/init.py 27 59.26%
blueprints/register.py 28 43.55%
resources/openid/idp_oauth2.py 53 50.23%
Totals Coverage Status
Change from base Build 17272232798: 0.2%
Covered Lines: 8360
Relevant Lines: 11160

💛 - Coveralls

@github-actions
Copy link

github-actions bot commented Aug 1, 2025

filepath passed failed skipped SUBTOTAL
tests/test_audit_service.py 2 1 3 6
tests/test_centralized_auth.py 9 7 0 16
tests/test_data_upload.py 6 2 1 9
tests/test_oauth2.py 9 6 0 15
tests/test_ras_authn.py 0 0 3 3
tests/test_dbgap.py 4 0 1 5
tests/test_register_user.py 0 0 2 2
tests/test_user_token.py 5 0 0 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_oidc_client.py 2 0 0 2
tests/test_google_data_access.py 1 0 0 1
tests/test_client_credentials.py 1 0 0 1
tests/test_presigned_url.py 7 0 0 7
TOTAL 50 16 10 76

Please find the detailed integration test report here (login here first)

@github-actions
Copy link

github-actions bot commented Aug 1, 2025

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 15 1 0 16
tests/test_data_upload.py 8 0 1 9
tests/test_google_data_access.py 1 0 0 1
tests/test_audit_service.py 3 0 3 6
TOTAL 42 1 4 47

Please find the detailed integration test report here (login here first)

@github-actions
Copy link

github-actions bot commented Aug 1, 2025

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here (login here first)

blueprint = flask.Blueprint("register", __name__)


def xor_with_user_email(form, field):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use this anymore when flask.g.user is not set anymore

return f"flask.request.remote_addr={flask.request.remote_addr} x_forwarded_headers={x_forwarded_headers}"


def login_user(
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 split login_user into _identify_user_and_update_database and login_user_unless_unregistered

{% endif %}
</li>
</ul>
<p>By registering and submitting this form, you hereby acknowledge and consent to be bound by our <a href="/dashboard/Public/documentation/DUA.html">data use agreement (DUA)</a>.</p><br>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding the change from #1149

config["OPENID_CONNECT"]["mock_idp"] = {"enable_idp_users_registration": False}


def test_login_existing_user_without_registration(app, db_session):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Registration-specific tests moved from tests/login/test_base.py, renamed for clarity, and fixed (see this):

test_login_existing_user
test_login_with_registration
test_login_with_missing_email
test_login_redirect_to_registration_page
test_login_redirect_after_authentication



@pytest.fixture
def mocks_for_idp_oauth2_callbacks(idp, rsa_private_key, mock_arborist_requests):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from tests/test_metrics.py for reusability

"generic_additional_params",
]
# some tests run on all the IdPs for which a login blueprint exists
def all_available_idps():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This results in fewer tests than LOGIN_IDPS and the same coverage (the generic implementation was tested multiple times).

The multiple generic logins with different configs are only needed in this test, which has its own parametrization

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here (login here first)

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here (login here first)

Copy link
Contributor

@nss10 nss10 left a comment

Choose a reason for hiding this comment

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

I’ve completed my first pass of the review, but I still need to go through the unit tests. Sharing my comments now so I don’t block you in the meantime

def get_registered_users():
"""
DEPRECATED: This endpoint is deprecated and will be removed in a future release.
Copy link
Contributor

Choose a reason for hiding this comment

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

If this function is no longer deprecated, this warning should be removed as well.

    logger.warning(
        f"Deprecated endpoint accessed: {request.path}. This endpoint is deprecated and will be removed in a future release."
    )

user_is_logged_in,
)

if flask.session.get("redirect"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we did not choose

if "redirect" in flask.session:

Just wanted to confirm—was it intentional to filter out both a missing 'redirect' key and an empty session['redirect']?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is existing code 🤷‍♀️ i see no reason to change it since the current version catches more cases

Copy link
Contributor

@nss10 nss10 left a comment

Choose a reason for hiding this comment

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

I’ve reviewed the rest of the changes — almost everything looks good. I just have a few small questions, that’s all.

from tests.conftest import all_available_idps


def test_contfest_idps():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_contfest_idps():
def test_conftest_idps():

Copy link
Contributor

Choose a reason for hiding this comment

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

I can make this change too. No worries.

OPENID_CONNECT, or the new file names do not match the convention and
cannot be parsed by this test.
If you added an IdP and this test fails, DO NOT edit this test. Either the
new IdP should be added to test-fence-config.yaml's OPENID_CONNECT+LOGIN_OPTIONS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
new IdP should be added to test-fence-config.yaml's OPENID_CONNECT+LOGIN_OPTIONS,
new IdP should be added to test-fence-config.yaml's OPENID_CONNECT and LOGIN_OPTIONS,

Comment on lines 22 to 24
enable_registration = (
hasattr(request, "param") and request.param.get("enable_registration")
) or True
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this always evaluate to True? Was that intentional. Could you explain the reason behind writing it this way?

Copy link
Contributor Author

@paulineribeyre paulineribeyre Aug 15, 2025

Choose a reason for hiding this comment

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

Oops, the goal was to default to True if request.param["enable_registration"] is None or not set. I think this does what i want:

enable_registration = (
    request.param.get("enable_registration", True) if hasattr(request, "param") else True
)

I haven't checked auto_register_users but i assume i made the same mistake

Copy link
Contributor

@nss10 nss10 Aug 17, 2025

Choose a reason for hiding this comment

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

Got it, thanks. I think we can just use:

enable_registration = getattr(request, "param", {}).get("enable_registration", True)

For auto_register_users, it already works fine since it defaults to False. If it’s overridden in the request as True, then True or False will evaluate to True.

That said, I’d prefer we keep both of them consistent for readability.

@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here

@nss10 nss10 self-requested a review August 28, 2025 05:10
@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here

@nss10 nss10 merged commit 5a20003 into master Aug 28, 2025
12 of 13 checks passed
@nss10 nss10 deleted the fix/registration branch August 28, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants