Skip to content

Commit

Permalink
Merge pull request #1525 from ScilifelabDataCentre/dev
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
rv0lt authored Apr 9, 2024
2 parents ef0761e + 2856b68 commit 781cacf
Show file tree
Hide file tree
Showing 17 changed files with 4,490 additions and 124 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog
==========

.. _2.6.4:

2.6.4 - 2023-04-10
~~~~~~~~~~~~~~~~~~~~~~~

- New features:
- Fix the files endpoint acording to openAPI standar .
- Added email contact to troubleshouting page
- Dependencies:
- `jwcrypto` from `1.5.1` to `1.5.6`
- Update base image for the docker containers from `python:3.10-alpine` to `python:3.11-alpine`

.. _2.6.3:

2.6.3 - 2023-02-27
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#############################

# Set official image -- parent image
FROM python:3.10-alpine as base
FROM python:3.11-alpine as base

ARG USERNAME=dds-user
ARG USER_UID=1001
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/cli.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set official image
FROM python:3.10-alpine as base
FROM python:3.11-alpine as base

# Update and upgrade
RUN apk update && apk upgrade
Expand Down
15 changes: 15 additions & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ _Nothing merged in CLI during this sprint_
- Minor update jinja2 package to address cve ([#1503](https://github.com/ScilifelabDataCentre/dds_web/pull/1503))
- Minor update jwcrypto package to address cve ([#1504](https://github.com/ScilifelabDataCentre/dds_web/pull/1504))

# 2023-01-15 - 2024-01-25

# 2024-01-15 - 2024-01-26

- Document Superadmin endpoints ([#1507](https://github.com/ScilifelabDataCentre/dds_web/pull/1507))
Expand All @@ -367,3 +369,16 @@ _Nothing merged in CLI during this sprint_

- Add link in footer for new User Agreement and Privacy Policy ([#1516](https://github.com/ScilifelabDataCentre/dds_web/pull/1516))
- New extra release, outside maintenance window, version 2.6.3 ([#1518](https://github.com/ScilifelabDataCentre/dds_web/pull/1518))

# 2024-03-11 - 2024-03-22

- Fix the files endpoints according to the openAPI standards, providing new endpoint version that co-exists with the current one ([#1505](https://github.com/ScilifelabDataCentre/dds_web/pull/1505))
- Added email to troubleshouting webpage, with obfuscation ([#1520](https://github.com/ScilifelabDataCentre/dds_web/pull/1520))

# 2024-03-25 - 2024-04-5

- Update base image and packages to address cve in docker containers ([#1523](https://github.com/ScilifelabDataCentre/dds_web/pull/1523))

# 2024-04-8 - 2024-04-19

- New version: 2.6.4 ([#1526](https://github.com/ScilifelabDataCentre/dds_web/pull/1526))
40 changes: 30 additions & 10 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ def prepare():
# Verify cli version compatible
if "api/v1" in flask.request.path:
verify_cli_version(version_cli=flask.request.headers.get("X-Cli-Version"))
elif "api/v3" in flask.request.path: # experimental v3 version
# If version api is not provided, it gets the data from the __version__ file
# When v3 is finallized, this should be removed and the __version__ file should be updated
pass

# Get message of the day
flask.g.motd = get_active_motds()
Expand Down Expand Up @@ -309,28 +313,44 @@ def dds_version_filter(_):
import dds_web.security.auth

# Register blueprints
from dds_web.api import api_blueprint
from dds_web.api import api_blueprint, api_blueprint_v3
from dds_web.web.root import pages
from dds_web.web.user import auth_blueprint
from flask_swagger_ui import get_swaggerui_blueprint

# url for the documentation
SWAGGER_URL = "/documentation"
# path where the swagger file is localted in the repository
API_URL = "/static/swagger.yaml"
# base url for the api documentation
SWAGGER_URL_1 = "/api/documentation/v1"
SWAGGER_URL_3 = "/api/documentation/v3"

# register blueprint for the documentation
swagger_ui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
# path where the swagger file(s) are localted in the repository
API_URL_V1 = "/static/swagger.yaml"
API_URL_V3 = "/static/swaggerv3.yaml"

# register blueprint(s) for the documentation
swagger_ui_blueprint_v1 = get_swaggerui_blueprint(
SWAGGER_URL_1,
API_URL_V1,
config={
"app_name": "DDS API Documentation",
"defaultModelsExpandDepth": -1,
"layout": "BaseLayout",
},
)
swagger_ui_blueprint_v3 = get_swaggerui_blueprint(
SWAGGER_URL_3,
API_URL_V3,
config={
"app_name": "DDS API Documentation",
"defaultModelsExpandDepth": -1,
"layout": "BaseLayout",
},
)
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)

# two documentation and api versions, v3 will contain the new endpoints fixed
app.register_blueprint(swagger_ui_blueprint_v1, url_prefix=SWAGGER_URL_1, name="v1")
app.register_blueprint(swagger_ui_blueprint_v3, url_prefix=SWAGGER_URL_3, name="v3")
app.register_blueprint(api_blueprint, url_prefix="/api/v1")
app.register_blueprint(api_blueprint_v3, url_prefix="/api/v3")
app.register_blueprint(pages, url_prefix="")
app.register_blueprint(auth_blueprint, url_prefix="")

Expand Down
138 changes: 75 additions & 63 deletions dds_web/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
api_blueprint = flask.Blueprint("api_blueprint", __name__)
api = flask_restful.Api(api_blueprint)

api_blueprint_v3 = flask.Blueprint("api_blueprint_v3", __name__)
api_v3 = flask_restful.Api(api_blueprint_v3)


@api.representation("application/json")
@api_v3.representation("application/json")
def output_json(data, code, headers=None):
resp = flask.make_response(flask.json.dumps(data), code)
resp.headers.extend(headers or {})
Expand All @@ -33,66 +37,74 @@ def output_json(data, code, headers=None):
####################################################################################################
# RESOURCES ############################################################################ RESOURCES #
####################################################################################################

# Login/access ###################################################################### Login/access #
api.add_resource(user.EncryptedToken, "/user/encrypted_token", endpoint="encrypted_token")
api.add_resource(user.SecondFactor, "/user/second_factor", endpoint="second_factor")

# S3 ########################################################################################## S3 #
api.add_resource(s3.S3Info, "/s3/proj", endpoint="proj_s3_info")

# Files #################################################################################### Files #
api.add_resource(files.NewFile, "/file/new", endpoint="new_file")
api.add_resource(files.MatchFiles, "/file/match", endpoint="match_files")
api.add_resource(files.ListFiles, "/files/list", endpoint="list_files")
api.add_resource(files.RemoveFile, "/file/rm", endpoint="remove_file")
api.add_resource(files.RemoveDir, "/file/rmdir", endpoint="remove_dir")
api.add_resource(files.FileInfo, "/file/info", endpoint="file_info")
api.add_resource(files.FileInfoAll, "/file/all/info", endpoint="all_file_info")
api.add_resource(files.UpdateFile, "/file/update", endpoint="update_file")
api.add_resource(files.AddFailedFiles, "/file/failed/add", endpoint="add_failed_files")

# Projects ############################################################################## Projects #
api.add_resource(project.UserProjects, "/proj/list", endpoint="list_projects")
api.add_resource(project.RemoveContents, "/proj/rm", endpoint="remove_contents")
api.add_resource(project.GetPublic, "/proj/public", endpoint="public_key")
api.add_resource(project.GetPrivate, "/proj/private", endpoint="private_key")
api.add_resource(project.CreateProject, "/proj/create", endpoint="create_project")
api.add_resource(project.ProjectUsers, "/proj/users", endpoint="list_project_users")
api.add_resource(project.ProjectStatus, "/proj/status", endpoint="project_status")
api.add_resource(project.ProjectAccess, "/proj/access", endpoint="project_access")
api.add_resource(project.ProjectBusy, "/proj/busy", endpoint="project_busy")
api.add_resource(project.ProjectInfo, "/proj/info", endpoint="project_info")

# User management ################################################################ User management #
api.add_resource(user.RetrieveUserInfo, "/user/info", endpoint="user_info")
api.add_resource(user.AddUser, "/user/add", endpoint="add_user")
api.add_resource(user.DeleteUser, "/user/delete", endpoint="delete_user")
api.add_resource(user.DeleteUserSelf, "/user/delete_self", endpoint="delete_user_self")
api.add_resource(user.RemoveUserAssociation, "/user/access/revoke", endpoint="revoke_from_project")
api.add_resource(user.UserActivation, "/user/activation", endpoint="user_activation")
api.add_resource(
user.RequestHOTPActivation, "/user/hotp/activate", endpoint="request_hotp_activation"
)
api.add_resource(
user.RequestTOTPActivation, "/user/totp/activate", endpoint="request_totp_activation"
)
api.add_resource(user.Users, "/users", endpoint="users")
api.add_resource(user.InvitedUsers, "/user/invites", endpoint="list_invites")

# Super Admins ###################################################################### Super Admins #

api.add_resource(superadmin_only.MaintenanceMode, "/maintenance", endpoint="maintenance")
api.add_resource(superadmin_only.AllUnits, "/unit/info/all", endpoint="all_units")
api.add_resource(superadmin_only.MOTD, "/motd", endpoint="motd")
api.add_resource(superadmin_only.SendMOTD, "/motd/send", endpoint="send_motd")
api.add_resource(superadmin_only.FindUser, "/user/find", endpoint="find_user")
api.add_resource(
superadmin_only.ResetTwoFactor, "/user/totp/deactivate", endpoint="reset_user_hotp"
)
api.add_resource(superadmin_only.AnyProjectsBusy, "/proj/busy/any", endpoint="projects_busy_any")
api.add_resource(superadmin_only.Statistics, "/stats", endpoint="stats")
api.add_resource(superadmin_only.UnitUserEmails, "/user/emails", endpoint="user_emails")

# Invoicing ############################################################################ Invoicing #
api.add_resource(user.ShowUsage, "/usage", endpoint="usage")
def add_resources(api):
# Login/access ###################################################################### Login/access #
api.add_resource(user.EncryptedToken, "/user/encrypted_token", endpoint="encrypted_token")
api.add_resource(user.SecondFactor, "/user/second_factor", endpoint="second_factor")

# S3 ########################################################################################## S3 #
api.add_resource(s3.S3Info, "/s3/proj", endpoint="proj_s3_info")

# Files #################################################################################### Files #
api.add_resource(files.NewFile, "/file/new", endpoint="new_file")
api.add_resource(files.MatchFiles, "/file/match", endpoint="match_files")
api.add_resource(files.ListFiles, "/files/list", endpoint="list_files")
api.add_resource(files.RemoveFile, "/file/rm", endpoint="remove_file")
api.add_resource(files.RemoveDir, "/file/rmdir", endpoint="remove_dir")
api.add_resource(files.FileInfo, "/file/info", endpoint="file_info")
api.add_resource(files.FileInfoAll, "/file/all/info", endpoint="all_file_info")
api.add_resource(files.UpdateFile, "/file/update", endpoint="update_file")
api.add_resource(files.AddFailedFiles, "/file/failed/add", endpoint="add_failed_files")

# Projects ############################################################################## Projects #
api.add_resource(project.UserProjects, "/proj/list", endpoint="list_projects")
api.add_resource(project.RemoveContents, "/proj/rm", endpoint="remove_contents")
api.add_resource(project.GetPublic, "/proj/public", endpoint="public_key")
api.add_resource(project.GetPrivate, "/proj/private", endpoint="private_key")
api.add_resource(project.CreateProject, "/proj/create", endpoint="create_project")
api.add_resource(project.ProjectUsers, "/proj/users", endpoint="list_project_users")
api.add_resource(project.ProjectStatus, "/proj/status", endpoint="project_status")
api.add_resource(project.ProjectAccess, "/proj/access", endpoint="project_access")
api.add_resource(project.ProjectBusy, "/proj/busy", endpoint="project_busy")
api.add_resource(project.ProjectInfo, "/proj/info", endpoint="project_info")

# User management ################################################################ User management #
api.add_resource(user.RetrieveUserInfo, "/user/info", endpoint="user_info")
api.add_resource(user.AddUser, "/user/add", endpoint="add_user")
api.add_resource(user.DeleteUser, "/user/delete", endpoint="delete_user")
api.add_resource(user.DeleteUserSelf, "/user/delete_self", endpoint="delete_user_self")
api.add_resource(
user.RemoveUserAssociation, "/user/access/revoke", endpoint="revoke_from_project"
)
api.add_resource(user.UserActivation, "/user/activation", endpoint="user_activation")
api.add_resource(
user.RequestHOTPActivation, "/user/hotp/activate", endpoint="request_hotp_activation"
)
api.add_resource(
user.RequestTOTPActivation, "/user/totp/activate", endpoint="request_totp_activation"
)
api.add_resource(user.Users, "/users", endpoint="users")
api.add_resource(user.InvitedUsers, "/user/invites", endpoint="list_invites")

# Super Admins ###################################################################### Super Admins #

api.add_resource(superadmin_only.MaintenanceMode, "/maintenance", endpoint="maintenance")
api.add_resource(superadmin_only.AllUnits, "/unit/info/all", endpoint="all_units")
api.add_resource(superadmin_only.MOTD, "/motd", endpoint="motd")
api.add_resource(superadmin_only.SendMOTD, "/motd/send", endpoint="send_motd")
api.add_resource(superadmin_only.FindUser, "/user/find", endpoint="find_user")
api.add_resource(
superadmin_only.ResetTwoFactor, "/user/totp/deactivate", endpoint="reset_user_hotp"
)
api.add_resource(
superadmin_only.AnyProjectsBusy, "/proj/busy/any", endpoint="projects_busy_any"
)
api.add_resource(superadmin_only.Statistics, "/stats", endpoint="stats")
api.add_resource(superadmin_only.UnitUserEmails, "/user/emails", endpoint="user_emails")

# Invoicing ############################################################################ Invoicing #
api.add_resource(user.ShowUsage, "/usage", endpoint="usage")


add_resources(api)
add_resources(api_v3)
Loading

0 comments on commit 781cacf

Please sign in to comment.