Skip to content

Commit

Permalink
fix(build): Preparing to build package for PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
monotasker committed Sep 23, 2024
1 parent e0edaa4 commit c7f1db0
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 223 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
63 changes: 63 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches:
- "main"
tags:
- v*
pull_request:
branches:
- main

env:
DOCKER_BUILDKIT: 1
TARGET_PLATFORMS: linux/amd64,linux/arm64
REGISTRY: ghcr.io
IMAGE_NAME: kcworks

jobs:
build_and_release:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v3

# Set up Python 3.9 environment
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: "3.9"

# Cache docker images so they don't rebuild every time
# - name: Cache Local Images
# id: local-images
# uses: actions/cache@v3
# with:
# path: /var/lib/docker/
# key: local-docker-directory

# - name: Build Images
# run: |
# docker compose up -d --build

# - name: Set up services
# run: |
# docker exec -it knowledgecommonsworks_web-ui_1 bash -c "bash ./scripts/setup-services.sh"
# exit

# - name: Build statics and assets
# run: |
# docker exec -it knowledgecommonsworks_web-ui_1 bash -c "bash ./scripts/build-assets.sh"
# exit

# - name: Run unit tests
# run: cd site && pytest

# - name: Stop services
# if: always()
# run: |
# docker compose down

4 changes: 2 additions & 2 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Installation
============

invenio-remote-user-data is on PyPI so all you need is:
invenio-remote-user-data-kcworks is on PyPI so all you need is:

.. code-block:: console
$ pip install invenio-remote-user-data
$ pip install invenio-remote-user-data-kcworks
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ verify_ssl = true
name = "pypi"

[packages]
invenio-app-rdm = "~=12.0.0b3.dev3"
invenio-app-rdm = "<13.0.0"
pytest = "*"
pytest-invenio = "*"
invenio-search = "*"
opensearch-dsl = "*"
invenio-utilities-tuw = "*"
invenio-queues = "*"
invenio-remote-user-data = {editable = true, path = "."}
invenio-remote-user-data-kcworks = {editable = true, path = "."}
requests-mock = "*"
deepdiff = "*"
celery = "*"
Expand All @@ -20,7 +20,7 @@ invenio-groups = {file = "../invenio-groups", editable = true}
[dev-packages]

[requires]
python_version = "3.9"
python_version = ">=3.9"

[pipenv]
allow_prereleases = true
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Invenio extension for drawing user and groups data from a Remote API.
# Invenio Remote User Data Service for Knowledge Commons Works

This extension provides a service to draw user and groups data from a remote service associated with a SAML login ID provider. This is user data that cannot be derived from the SAML response itself at login, but must be pulled separately from an API endpoint exposed by the same service. This extension assumes the existence of two API endpoints exposed by the remote service: one for user data and one for group data.
Version 0.5.2-beta1

* Beta release *

This extension for the Knowledge Commons Works installation of InvenioRDM provides a service to draw user and groups data from a remote service associated with a SAML login ID provider. This is user data that cannot be derived from the SAML response itself at login, but must be pulled separately from an API endpoint exposed by the same service. This extension assumes the existence of two API endpoints exposed by the remote service: one for user data and one for group data.

Although this extension was developed for the Knowledge Commons Works installation of InvenioRDM, it could be adapted to other installations of InvenioRDM or other remote services. Most of the changes needed would be in the integration of group collection memberships via the `invenio_group_collections_kcworks` extension.

## Linking Invenio roles and collections with remote service groups

Expand All @@ -20,7 +26,7 @@ The service's update operations are triggered in two ways: automatically when a

### Automatic update at login

When a user logs in, the `invenio_remote_user_data` extension checks to see whether the current user logged in with a SAML provider. If so, it sends an API request to the appropriate remote API associated with that remote service (configured via a variable in the instance's `invenio.cfg` file) and stores or updates the user's data from the remote service in the user's Invenio account metadata.
When a user logs in, the `invenio_remote_user_data_kcworks` extension checks to see whether the current user logged in with a SAML provider. If so, it sends an API request to the appropriate remote API associated with that remote service (configured via a variable in the instance's `invenio.cfg` file) and stores or updates the user's data from the remote service in the user's Invenio account metadata.

Only user metadata updates take place automatically at login. These include updates to the user's group memberships on the remote service, but this user update operation does not update any of the metadata for the groups themselves. Group metadata updates are only triggered by the webhook signal.

Expand Down
6 changes: 3 additions & 3 deletions authors.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
..
Copyright (C) 2023 MESH Research
Copyright (C) 2024 MESH Research
invenio-remote-user-data is free software; you can redistribute it and/or
invenio-remote-user-data-kcworks is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
details.

Authors
=======

Extension to allow for remote user data to be passed to Invenio.
Extension to allow for remote user data to be passed to the Knowledge Commons Works installation of InvenioRDM.

- Mesh Research <scottia4@msu.edu>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand Down Expand Up @@ -34,7 +34,7 @@
on the Invenio server, the `groups` service will handle creation of the
group. If a user is the last member of a group and is removed, the
`groups` service deletes the group (i.e., the invenio-accounts role).
The `remote-user-data` service, though, only sends the signal for the
The `remote-user-data-kcworks` service, though, only sends the signal for the
`groups` service to add or remove the user from the group.
Note that the group membership updates are one-directional. If a user is
Expand Down Expand Up @@ -106,7 +106,7 @@
Logging
-------
The `remote-user-data` extension will log each POST request to the webhook
The `remote-user-data-kcworks` extension will log each POST request to the webhook
endpoint, each signal received, and each task initiated to update the data.
These logs will be written to a dedicated log file,
`logs/remote_data_updates.log`.
Expand Down Expand Up @@ -229,6 +229,6 @@
from __future__ import absolute_import, print_function
from .ext import InvenioRemoteUserData

__version__ = "1.0.0a"
__version__ = "0.5.2-beta1"

__all__ = ("__version__", "InvenioRemoteUserData")
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand All @@ -28,7 +28,8 @@ def on_user_logged_in(_, user: User) -> None:

with current_app.app_context():
current_app.logger.info(
"invenio_remote_user_data.ext: user_logged_in signal received "
"invenio_remote_user_data_kcworks.ext: user_logged_in "
"signal received "
f"for user {user.id}"
)
current_app.logger.debug(f"current_user: {current_user}")
Expand Down Expand Up @@ -66,7 +67,7 @@ def on_user_logged_in(_, user: User) -> None:


class InvenioRemoteUserData(object):
"""Flask extension for Invenio-remote-user-data.
"""Flask extension for Invenio-remote-user-data-kcworks.
Args:
object (_type_): _description_
Expand All @@ -87,7 +88,7 @@ def init_app(self, app) -> None:
self.init_config(app)
self.init_services(app)
self.init_listeners(app)
app.extensions["invenio-remote-user-data"] = self
app.extensions["invenio-remote-user-data-kcworks"] = self

def init_config(self, app) -> None:
"""Initialize configuration for the extention.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from werkzeug.local import LocalProxy

current_remote_user_data = LocalProxy(
lambda: current_app.extensions["invenio-remote-user-data"]
lambda: current_app.extensions["invenio-remote-user-data-kcworks"]
)

current_remote_user_data_service = LocalProxy(
lambda: current_remote_user_data.service
)

current_remote_group_data_service = LocalProxy(
current_remote_group_service = LocalProxy(
lambda: current_remote_user_data.group_service
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

Expand Down Expand Up @@ -144,7 +144,7 @@ def update_group_from_remote(
return dictionary.
This method is triggered by the
:class:`invenio_remote_user_data.views.RemoteUserDataUpdateWebhook`
:class:`invenio_remote_user_data_kcworks.views.RemoteUserDataUpdateWebhook`
view.
Parameters:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
#
# This file is part of the invenio-remote-user-data package.
# This file is part of the invenio-remote-user-data-kcworks package.
# Copyright (C) 2023, MESH Research.
#
# invenio-remote-user-data is free software; you can redistribute it
# invenio-remote-user-data-kcworks is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see
# LICENSE file for more details.

"""Signals for invenio-remote-user-data."""
"""Signals for invenio-remote-user-data-kcworks."""

from blinker import Namespace

Expand Down
Loading

0 comments on commit c7f1db0

Please sign in to comment.