Skip to content

shared secret mismatches throw errors #808

Description

@aronatkins

Given any Plumber API, for versions of plumber up to 1.1.0:

options(`plumber.sharedSecret`="abcdefg")
plumber::plumb(file='plumber.R')$run()
# On connecting to this application:
# <simpleError in (function (req, res) {    secret <- getOption("plumber.sharedSecret", NULL)    if (!is.null(secret)) {        supplied <- req$HTTP_PLUMBER_SHARED_SECRET        if (!identical(supplied, secret)) {            res$status <- 400            stop("The provided shared secret did not match expected secret.")        }    }    forward()})(req = <environment>, res = <environment>): The provided shared secret did not match expected secret.>

Interacting with that API gives:

curl http://127.0.0.1:3063/echo
# {"error":"Internal error","message":"Error in (function (req, res) : The provided shared secret did not match expected secret.\n"}

It is not necessary to use stop; returning an error response is sufficient.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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