Package: edrn.auth
🔑 EDRN AuthThis is aDjangoapp (that is,Pythonpackage) that provides authentication and authorization for theportal for the Early Detection Research Networkand other applications. You use it with theWagtail CMS.It currently works with:Wagtail versions less than 6 but greater than 5Djangoversions less than 5 but greater than 4Pythonversions 3.11 or greater (but probably less than 4)💁 How to Use ItSimply addedrn.authto your list of dependencies and install it (such as inrequirements.txtorpyproject.toml'sdependencies)), then add it your site'sINSTALLED_APPS. Next you'll want to importedrn.auth's URL patterns with something like this in your ownurls.py:fromedrn.auth.urlsimporturlpatternsasedrn_auth_urlpatterns…urlpatterns=edrn_auth_urlpatterns+[# your own URL patterns]This will give you several URL paths:_util/login/for logging in, overriding the Wagtail frontend login template, with the full U.S. government boilerplate and the three login alternatives (portal, LabCAS, DMCC "secure" site)_util/portal-login(namedportal_login), for logging in, with the full U.S. government boilerplate but only portal login (LabCAS and DMCC "secure" site are not mentioend)logout/(namedlogout), for logging outauthentication-test(namedauthentication-test), for testing if credentials are valid, using HTTP BasicThere are several utilities you can import fromedrn.auth.views, which are described below.🔐view_or_basicauthview_or_basicauthis used as a decorator on a view along with a test function,test_func. Thetest_funcis expected to receive a single argument, the DjangoHTTPRequest.user.If the test function succeeds, the decorated view is returned. Otherwise, if HTTP Basic authentication is present and succeeds, the decorated view is returned.Otherwise, the HTTP "unauthorized" status is returned with an HTTP Basic challenge.🔒logged_in_or_basicauthThe decoratorlogged_in_or_basicauthjust uses the above view with thetest_funcset touser.is_authenticated.🔏authentication_contextThe functionauthentication_contexttakes a DjangoHTTPRequestand based on its state, returns a dictionary with the following values:authenticated:Trueif there's an authenticated user present,Falseotherwiselogout: The URL to visit to have the current user logout, if applicablelogin: The URL to visit to present a full login page (with the three alternative destinations, portal, LabCAS, and DMCC "secure" site)portal_login: The URL to visit to present the portal-only login pageThis is intended to be used inget_contextmethods or views to provide handy links.🥖 TranslationsThis package hasn't be translated into any other languages aside from US English.👏 ContributingAll of the developers of this package are expected to abide by ourCode of Conduct. Do check it out! We don't take this lightly and we have high standards of our community. For information on how to contribute software to the Early Detection Research Network, check out ourcontributor guidelines.🎈 SupportIf you're experiencing issues, view to see if an issue's been filed (or file a fresh one) at ourissue tracker. Or you can reach usby email.🪪 LicenseThis package is licensed under the Apache License, version 2. See theLICENSE.mdfile for details.