Skip to content

Commit

Permalink
Add chatAuthBypassEnabled setting
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickMythril committed Apr 4, 2024
1 parent d54f840 commit 9daf357
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/qortal/api/resource/ChatResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.qortal.repository.DataException;
import org.qortal.repository.Repository;
import org.qortal.repository.RepositoryManager;
import org.qortal.settings.Settings;
import org.qortal.transaction.ChatTransaction;
import org.qortal.transaction.Transaction;
import org.qortal.transaction.Transaction.TransactionType;
Expand Down Expand Up @@ -273,7 +274,8 @@ public ActiveChats getActiveChats(@PathParam("address") String address, @QueryPa
@ApiErrors({ApiError.TRANSACTION_INVALID, ApiError.TRANSFORMATION_ERROR, ApiError.REPOSITORY_ISSUE})
@SecurityRequirement(name = "apiKey")
public String buildChat(@HeaderParam(Security.API_KEY_HEADER) String apiKey, ChatTransactionData transactionData) {
Security.checkApiCallAllowed(request);
if (!Settings.getInstance().isChatAuthBypassEnabled())
Security.checkApiCallAllowed(request);

try (final Repository repository = RepositoryManager.getRepository()) {
ChatTransaction chatTransaction = (ChatTransaction) Transaction.fromData(repository, transactionData);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/qortal/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ public class Settings {
/** Whether to serve QDN data without authentication */
private boolean qdnAuthBypassEnabled = true;

/** Whether to accept CHAT transactions without authentication */
private boolean chatAuthBypassEnabled = false;

/** Limit threads per message type */
private Set<ThreadLimit> maxThreadsPerMessageType = new HashSet<>();

Expand Down Expand Up @@ -1110,6 +1113,10 @@ public boolean isQDNAuthBypassEnabled() {
return this.qdnAuthBypassEnabled;
}

public boolean isChatAuthBypassEnabled() {
return this.chatAuthBypassEnabled;
}

public Integer getMaxThreadsForMessageType(MessageType messageType) {
if (maxThreadsPerMessageType != null) {
for (ThreadLimit threadLimit : maxThreadsPerMessageType) {
Expand Down

0 comments on commit 9daf357

Please sign in to comment.