R/checkPermissivePrivacyControlLevel.R

Defines functions checkPermissivePrivacyControlLevel

Documented in checkPermissivePrivacyControlLevel

#'
#' @title checkPermissivePrivacyControlLevel
#' @description This server-side function check that the server is running in "permissive" privacy control level.
#' @details Tests whether the R option "datashield.privacyControlLevel" is set to "permissive", if it isn't
#' will cause a call to stop() with the message "BLOCKED: The server is running in 'non-permissive' mode which 
#' has caused this method to be blocked".
#' @param privacyControlLevels is a vector of strings which contains the privacy control level names which are permitted by the calling method.
#' 
#' @author Wheater, Dr SM., DataSHIELD Development Team.
#' 
#' @return No return value, called for side effects
#' @export
#'
checkPermissivePrivacyControlLevel <- function(privacyControlLevels){

    disclosureSettings <- dsBase::listDisclosureSettingsDS()
    if (is.null(disclosureSettings) || is.null(disclosureSettings$datashield.privacyControlLevel) ||
        (! any(disclosureSettings$datashield.privacyControlLevel %in% privacyControlLevels))) {
        stop("BLOCKED: The server is running in 'non-permissive' mode which has caused this method to be blocked", call. = TRUE)
    }

    invisible()   
}

Try the dsBase package in your browser

Any scripts or data that you put into this service are public.

dsBase documentation built on Aug. 8, 2025, 6:05 p.m.