Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chatAuthBypassEnabled setting #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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
Loading