Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ SSH_SERVER_PORT_LAN=
# Disable the DELETE feature
#DISABLE_DELETE_REPO=true

# Do not allow to remove append-only mode, once set
#DISABLE_REVERT_APPEND_ONLY=true

# Disable the integrations (API tokens to CRUD repositories)
#DISABLE_INTEGRATIONS=true

Expand All @@ -50,4 +53,4 @@ MAIL_SMTP_PWD=
MAIL_REJECT_SELFSIGNED_TLS=

# Force app to start on IPv6
#HOSTNAME=::
#HOSTNAME=::
16 changes: 12 additions & 4 deletions Containers/RepoManage/RepoManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,18 @@ export default function RepoManage(props: RepoManageProps) {
);
router.replace('/');
} else {
const errorMessage = await response.json();
toast.error(`An error has occurred : ${errorMessage.message.stderr}`, toastOptions);
router.replace('/');
console.log(`Fail to ${props.mode}`);
if (response.status == 403) {
toast.warning(
'🔒 The server is currently protected against reverting append-only mode.',
toastOptions
);
router.replace('/');
} else {
const errorMessage = await response.json();
toast.error(`An error has occurred : ${errorMessage.message.stderr}`, toastOptions);
router.replace('/');
console.log(`Fail to ${props.mode}`);
}
}
})
.catch((error) => {
Expand Down
9 changes: 9 additions & 0 deletions pages/api/v1/repositories/[slug]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ export default async function handler(
'The SSH key is already used in another repository. Please use another key or delete the key from the other repository.',
});
}
if (repo.appendOnlyMode && appendOnlyMode === false) {
if (process.env.DISABLE_REVERT_APPEND_ONLY === "true") {
res.status(403).json({
status: 403,
message: 'Reverting Append-Only mode is disabled on this server',
});
return;
}
}

const updatedRepo: Repository = {
...repo,
Expand Down