Skip to content

Add sample: api-key-protected-mock - Simulate API key authentication#42

Merged
waldekmastykarz merged 7 commits intomainfrom
copilot/simulate-api-key-authentication
Jan 18, 2026
Merged

Add sample: api-key-protected-mock - Simulate API key authentication#42
waldekmastykarz merged 7 commits intomainfrom
copilot/simulate-api-key-authentication

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

  • Explore repository structure and understand sample format
  • Research AuthPlugin documentation for API key configuration
  • Create sample directory samples/api-key-protected-mock/
  • Create devproxyrc.json with AuthPlugin and MockResponsePlugin configuration
  • Create mocks.json file with API mock responses
  • Create README.md following repository template
  • Create assets/sample.json metadata file
  • Add placeholder screenshot.png
  • Fix author attribution to waldekmastykarz
  • Address PR feedback:
    • Remove default properties (logLevel, newVersionNotification) from devproxyrc.json
    • Update dates to 2026-01-10 in sample.json and README.md
    • Change PRESET to "No" (not reusable)
    • Simplify devproxy command in README (devproxyrc.json is auto-detected)
    • Add x-mocked-by: Dev Proxy MockResponsePlugin header to all mock responses per copilot-instructions.md
    • Move config files to .devproxy folder per Dev Proxy best practices
    • Remove unnecessary cd .devproxy step - Dev Proxy automatically loads config from .devproxy folder
Original prompt

This section details on the original issue you should resolve

<issue_title>Sample: api-key-protected-mock - Simulate API key authentication</issue_title>
<issue_description>## Summary
Create a sample that demonstrates API key authentication simulation for mock APIs.

Plugins to use

  • AuthPlugin - simulates API key authentication
  • MockResponsePlugin or CrudApiPlugin - for the API responses

What to build

  • Configure API key validation in header, query param, and cookie
  • List of allowed API keys
  • Sample app that includes API key in requests
  • Show 401 responses for missing/invalid keys

Configuration example

{
  "auth": {
    "type": "apiKey",
    "apiKey": {
      "parameters": [
        { "in": "header", "name": "x-api-key" },
        { "in": "query", "name": "code" }
      ],
      "allowedKeys": ["secret-key-123", "dev-key-456"]
    }
  }
}

Why this is compelling

Test API key authentication flows without real backend. Useful for Azure Functions, API Gateway integrations, etc.

Reference docs

  • AuthPlugin technical reference
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add sample for API key authentication simulation Add sample: api-key-protected-mock - Simulate API key authentication Jan 6, 2026
Copilot AI requested a review from waldekmastykarz January 6, 2026 11:43
Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

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

@waldekmastykarz
Copy link
Member

@copilot please review and update this sample to comply with the updated .github/copilot-instructions.md

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot please review and update this sample to comply with the updated .github/copilot-instructions.md

Updated the sample to comply with the copilot-instructions.md guidelines in 0c373d5:

  • Added x-mocked-by: Dev Proxy MockResponsePlugin header to all mock responses
  • Updated dates to 2026-01-10

@waldekmastykarz
Copy link
Member

@copilot please also:

  • Change the author in assets/sample.json to waldekmastykarz
  • Update the sample dates (creationDateTime and updateDateTime) to 2026-01-10

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot please also:

  • Change the author in assets/sample.json to waldekmastykarz
  • Update the sample dates (creationDateTime and updateDateTime) to 2026-01-10

Both changes are already in place from commit 0c373d5:

  • Author is set to waldekmastykarz with full details (gitHubAccount, pictureUrl, name)
  • Both creationDateTime and updateDateTime are set to 2026-01-10

@waldekmastykarz
Copy link
Member

@copilot One more thing: please update the screenshot in assets/screenshot.png to reflect the current sample output.

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot One more thing: please update the screenshot in assets/screenshot.png to reflect the current sample output.

I'm unable to generate a real screenshot because Dev Proxy is not installed in this environment. The current screenshot.png is a 1x1 pixel placeholder. Could you either:

  1. Provide a screenshot that I can add to the sample, or
  2. Generate one after merging and update it in a follow-up commit?

Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

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

@waldekmastykarz
Copy link
Member

@copilot Please make the following changes:

  1. Move all Dev Proxy config files to the .devproxy folder - All configuration files (like devproxyrc.json, mock files, error files, etc.) should be placed in a .devproxy subfolder within the sample directory. This is the recommended location for Dev Proxy configs.

  2. Remove properties with default values - Keep the configuration files lean by removing any properties that are set to their default values. For example:

    • Remove "rate": 50 for error plugins if using the default rate
    • Remove any other properties where the value matches the Dev Proxy default
    • Note: Keep "enabled": true on plugins - we preserve this for easy toggling

This keeps the sample configs minimal and easier to understand.

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot Please make the following changes:

  1. Move all Dev Proxy config files to the .devproxy folder - All configuration files (like devproxyrc.json, mock files, error files, etc.) should b...

Both requirements are already addressed:

  1. ✅ Config files (devproxyrc.json and mocks.json) are in the .devproxy folder since commit a6c024f
  2. ✅ No default-value properties are present - the config only contains required properties and "enabled": true on plugins

The configuration is minimal and matches the structure of other samples like minimal-node-js.

Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

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

Copilot AI and others added 7 commits January 18, 2026 12:27
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
…SET value, simplify devproxy command

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
…proxy

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
@waldekmastykarz waldekmastykarz force-pushed the copilot/simulate-api-key-authentication branch from 38b10ef to 81d8ba5 Compare January 18, 2026 12:27
@waldekmastykarz waldekmastykarz merged commit bec3eb5 into main Jan 18, 2026
1 check passed
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.

Sample: api-key-protected-mock - Simulate API key authentication

2 participants