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

global: explicitly set and use hide attribute for config #326

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

rekt-hard
Copy link
Contributor

❤️ Thank you for your contribution!

Description

A hide attribute is accessed at some places within the existing code already. These changes will explicitly set this attribute and use it in other places in the code as well. This will allow to hide login with an external account, while at the same time, allow to link an external account in the profile view.

Per default, hide will evaluate to False in order to be compliant with the current logic.

Example config:

def anon_user():
    return not current_user.is_authenticated

helper = k.KeycloakSettingsHelper(
    title="Local KeyCloak",
    description="My organization authentication provider",
    base_url="http://localhost:8087",
    realm="damap",
    # hide_when=anon_user
)

OAUTHCLIENT_REMOTE_APPS = dict(
    orcid={
        **orcid.REMOTE_APP,
        "hide": LocalProxy(lambda: anon_user()),
    },
    keycloak={
        **helper.remote_app,
    },
)

Login only via local keycloak:
image

Linking of accounts with ORCID also possible:
image

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Third-party code

If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

Copy link
Contributor

@max-moser max-moser left a comment

Choose a reason for hiding this comment

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

For the record, the hide flag already exists in the code prior to this PR, so the mechanism isn't new but just made actually usable.

@max-moser
Copy link
Contributor

@rekt-hard suggested disabling the /oauth/<remote-app>/ endpoint if the hide config for <remote-app> evaluates to True.
Otherwise, users can still use that OP to authenticate, even if it's hidden.
I'll merge this PR once that functionality is added.

For dynamic cases (e.g. only allow a given OP for linking but not registering), see the example configuration.

@max-moser max-moser merged commit 2f84cf9 into inveniosoftware:master Sep 11, 2024
@rekt-hard rekt-hard deleted the hide-config branch September 12, 2024 08:00
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.

3 participants