Skip to content

✨(backend) add resource server api#1923

Open
Ash-Crow wants to merge 1 commit intomainfrom
sbl-ressource-server
Open

✨(backend) add resource server api#1923
Ash-Crow wants to merge 1 commit intomainfrom
sbl-ressource-server

Conversation

@Ash-Crow
Copy link
Collaborator

@Ash-Crow Ash-Crow commented Feb 26, 2026

Purpose

Adds a resource server API similar to the one that already exists for Drive.

Proposal

  • Add a new resource_server API with four endpoints : documents, document_accesses, document_invitation, users, along with unit tests that check that :
    • anonymous users can't use these endpoints
    • logged-in users can't use the endpoints that are not active by default
    • for each action that is allowed by default, that it works
    • for each action that is not allowed by default, that is is forbidden, and works if explicitely allowed (see detailed list below)
  • Add a documentation for the new API at docs/resource_server.md.
  • Fix some intermittent errors in other unit tests
  • Fix some missing entries in the DocumentViewSet docstring.

List of actions for each endpoint

  • For documents:

    • list (allowed by default)
    • retrieve (allowed by default)
    • create (allowed by default)
    • update
    • delete
    • trashbin
    • restore → added to the documentation, it was missing
    • move → added to the documentation, it was missing
    • duplicate → bypasses restriction checks, so always allowed for logged-in users
    • children (allowed by default)
    • versions_list
    • versions_detail
    • favorite_list → bypasses restriction checks, so always allowed for logged-in users
    • favorite
    • create-for-owner → not allowed.
    • link_configuration
    • attachment_upload
    • media_auth
    • ai_transform
    • ai_translate
    • ai_proxy
  • For document accesses:

    • list
    • retrieve
    • create
    • update
    • partial_update
    • destroy
  • For invitations:

    • list
    • retrieve
    • create
    • partial_update
    • destroy
  • For users:

    • get_me (allowed by default)
    • check that other actions are not allowed

@Ash-Crow Ash-Crow force-pushed the sbl-ressource-server branch 12 times, most recently from 939199e to 7a26391 Compare March 4, 2026 10:26
Adds a resource server API similar to the one that already
exists for Drive.
@Ash-Crow Ash-Crow force-pushed the sbl-ressource-server branch from 7a26391 to a4dfd39 Compare March 4, 2026 11:26
@Ash-Crow Ash-Crow marked this pull request as ready for review March 4, 2026 11:45
@Ash-Crow Ash-Crow requested a review from lunika March 4, 2026 11:46
Comment on lines +71 to +95
def create_document_from_markdown(self, request):
"""
Create a new document from a Markdown file at root level.
"""

# Get the access token from the session
access_token = request.session.get('oidc_access_token')

# Create a new document from a file
file_content = b"# Test Document\n\nThis is a test."
file = BytesIO(file_content)
file.name = "readme.md"

response = requests.post(
f"{settings.DOCS_API}/documents/",
{
"file": file,
},
format="multipart",
)

response.raise_for_status()
data = response.json()
return {"id": data["id"]}
```
Copy link
Member

Choose a reason for hiding this comment

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

This example does not work for Docs, only for Drive.


# Check if the user is authenticated
if not request.user.is_authenticated:
return False
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return False
return False

@virgile-dev virgile-dev mentioned this pull request Mar 9, 2026
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.

2 participants