diff --git a/.env.example b/.env.example index bc71dbb0d9..d112c5c9dd 100644 --- a/.env.example +++ b/.env.example @@ -104,6 +104,14 @@ ORCID_CLIENT_ID=SECRET ORCID_CLIENT_SECRET=SECRET ORCID_SCOPE='/read-limited,/activities/update' ORCID_LOGIN_ENABLED=True +ORCID_DOMAIN=https://sandbox.orcid.org +ORCID_LOGIN_REDIRECT_URI=http://localhost:8000/authorcid_login +ORCID_AUTH_URL=https://sandbox.orcid.org/oauth/authorize +ORCID_TOKEN_URL=https://sandbox.orcid.org/oauth/token +ORCID_LOGIN_ENABLED=False +ORCID_LOGIN_BUTTON_TEXT="Log in using ORCID iD" +# JWKS is used to get public key from orcid and validate access token using this public key +ORCID_OPEN_ID_JWKS_URL=https://sandbox.orcid.org/oauth/jwks STORAGE_TYPE=LOCAL diff --git a/physionet-django/physionet/settings/base.py b/physionet-django/physionet/settings/base.py index 04d48dfff4..a94095d08a 100644 --- a/physionet-django/physionet/settings/base.py +++ b/physionet-django/physionet/settings/base.py @@ -35,6 +35,20 @@ GCS_SIGNED_URL_LIFETIME_IN_MINUTES = config('GCS_SIGNED_URL_LIFETIME_IN_MINUTES', default=1440, cast=int) +# Tags for the ORCID API +ORCID_DOMAIN = config('ORCID_DOMAIN', default='https://sandbox.orcid.org') +ORCID_REDIRECT_URI = config('ORCID_REDIRECT_URI', default='http://127.0.0.1:8000/authorcid') +ORCID_LOGIN_REDIRECT_URI = config('ORCID_LOGIN_REDIRECT_URI', default='http://127.0.0.1:8000/authorcid_login') +ORCID_AUTH_URL = config('ORCID_AUTH_URL', default='https://sandbox.orcid.org/oauth/authorize') +ORCID_TOKEN_URL = config('ORCID_TOKEN_URL', default='https://sandbox.orcid.org/oauth/token') +ORCID_CLIENT_ID = config('ORCID_CLIENT_ID', default=False) +ORCID_CLIENT_SECRET = config('ORCID_CLIENT_SECRET', default=False) +ORCID_SCOPE = config('ORCID_SCOPE', default=False) +ORCID_LOGIN_ENABLED = config('ORCID_LOGIN_ENABLED', default=False) +ORCID_OPEN_ID_JWKS_URL = config('ORCID_OPEN_ID_JWKS_URL', default=False) +ORCID_LOGIN_BUTTON_TEXT = config('ORCID_LOGIN_BUTTON_TEXT', default="Log in using ORCID iD") + + # Application definition INSTALLED_APPS = [ @@ -150,7 +164,9 @@ }, ] -AUTHENTICATION_BACKENDS = ['user.backends.DualAuthModelBackend', 'user.backends.OrcidAuthBackend'] +AUTHENTICATION_BACKENDS = ['user.backends.DualAuthModelBackend'] +if ORCID_LOGIN_ENABLED: + AUTHENTICATION_BACKENDS.append('user.backends.OrcidAuthBackend') if ENABLE_SSO: AUTHENTICATION_BACKENDS += ['sso.auth.RemoteUserBackend'] @@ -278,18 +294,6 @@ DATACITE_USER = config('DATACITE_USER', default='') DATACITE_PASS = config('DATACITE_PASS', default='') -# Tags for the ORCID API -ORCID_DOMAIN = config('ORCID_DOMAIN', default='https://sandbox.orcid.org') -ORCID_REDIRECT_URI = config('ORCID_REDIRECT_URI', default='http://127.0.0.1:8000/authorcid') -ORCID_LOGIN_REDIRECT_URI = config('ORCID_LOGIN_REDIRECT_URI', default='http://127.0.0.1:8000/authorcid_login') -ORCID_AUTH_URL = config('ORCID_AUTH_URL', default='https://sandbox.orcid.org/oauth/authorize') -ORCID_TOKEN_URL = config('ORCID_TOKEN_URL', default='https://sandbox.orcid.org/oauth/token') -ORCID_CLIENT_ID = config('ORCID_CLIENT_ID', default=False) -ORCID_CLIENT_SECRET = config('ORCID_CLIENT_SECRET', default=False) -ORCID_SCOPE = config('ORCID_SCOPE', default=False) -ORCID_LOGIN_ENABLED = config('ORCID_LOGIN_ENABLED', default=("openid" in ORCID_SCOPE)) -ORCID_OPEN_ID_JWKS_URL = config('ORCID_OPEN_ID_JWKS_URL', default=False) - # Tags for the CITISOAPService API CITI_USERNAME = config('CITI_USERNAME', default='') CITI_PASSWORD = config('CITI_PASSWORD', default='') diff --git a/physionet-django/sso/templates/sso/login.html b/physionet-django/sso/templates/sso/login.html index dc12f680db..0fe0d02222 100644 --- a/physionet-django/sso/templates/sso/login.html +++ b/physionet-django/sso/templates/sso/login.html @@ -21,17 +21,19 @@