Skip to content

How to change the signalr emulator access keys? #2174

@tweaktheboss

Description

@tweaktheboss

I searched the whole web regarding it and there is really no information about changing the default access key: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGH

Endpoint=http://0.0.0.0;Port=8888;AccessKey=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGH;Version=1.0

I want to change the access keys, is that possible?

This is my dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:8.0

# Create and switch to a non-root user
RUN useradd -ms /bin/bash nonroot && \
    mkdir -p /home/nonroot/signalr && \
    chown -R nonroot:nonroot /home/nonroot

USER nonroot
WORKDIR /home/nonroot/signalr

# Install the SignalR Emulator
RUN dotnet tool install --global Microsoft.Azure.SignalR.Emulator

# Update PATH to include user's dotnet tools
ENV PATH="/home/nonroot/.dotnet/tools:${PATH}"

# Start the emulator with the custom access key
ENTRYPOINT ["asrs-emulator", "start", "-i", "0.0.0.0"]

My docker compose:

  signalr-emulator:
    container_name: signalr-emulator
    image: signalr-emulator:latest
    build:
      dockerfile: signalr/Dockerfile
    networks:
      - marble-network
    env_file:
      - .env.signalr
    volumes:
      - signalr:/home/nonroot/.aspnet
      - ./signalr/signalr-settings.json:/home/nonroot/signalr/settings.json
      - ./signalr/signalr-appsettings.json:/home/nonroot/signalr/appsettings.json
    ports:
      - "7071:7071"
      - "9999:8888"

signalr-appsettings.json

{
    "Logging": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Warning"
      }
    },
    "AllowedHosts": "*",
    "AccessKey": "This key is not working but included in: https://github.com/Azure/azure-signalr/blob/dev/src/Microsoft.Azure.SignalR.Emulator/appsettings.json and the file is being read according to the logs when running 'asrs-emulator start -i 0.0.0.0' | I also looked at the source code of the said repo, and it seems that the Access Key is hardcoded??"
}

signalr-settings.json

{
    "UpstreamSettings": {
        "Templates": [
            {
                "UrlTemplate": "http://0.0.0.0:7071/runtime/webhooks/signalr",
                "EventPattern": "*",
                "HubPattern": "*",
                "CategoryPattern": "*"
            }
        ]
    }
}

My main issue is where do i set the custom access key? Is it on an environment or a parameter in asrs-emulator? Because according to it's help command, there is no such parameter for setting the custom access key. Its fixed to this:

Endpoint=http://0.0.0.0;Port=8888;AccessKey=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGH;Version=1.0

References:
#969

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions