| GuardBasic | R Documentation |
This class encapsulates the logic of the
Basic authentication scheme.
See guard_basic() for more information.
fireproof::Guard -> GuardBasic
open_apiAn OpenID compliant security scheme description
new()Constructor for the class
GuardBasic$new(validate, user_info = NULL, realm = "private", name = NULL)
validateA function that will be called with the arguments
username, password, realm, request, and response and returns TRUE
if the user is valid, and FALSE otherwise. If the function returns a
character vector it is considered to be authenticated and the return value
will be understood as scopes the user is granted.
user_infoA function to extract user information from the
username. It is called with a single argument: user which is the username
used for the successful authentication. The function should return a new
user_info list.
realmThe realm this authentication corresponds to. Will be returned to the client on a failed authentication attempt to inform them of the credentials required, though most often these days it is kept from the user.
nameThe name of the authentication
check_request()A function that validates an incoming request, returning
TRUE if it is valid and FALSE if not. It decodes the credentials in
the Authorization header, splits it into username and password and then
calls the validate function provided at construction.
GuardBasic$check_request(request, response, keys, ..., .datastore)
requestThe request to validate as a Request object
responseThe corresponding response to the request as a Response object
keysA named list of path parameters from the path matching
...Ignored
.datastoreThe data storage from firesale
reject_response()Upon rejection this scheme sets the response status to 401
and sets the WWW-Authenticate header to
Basic realm="<realm>", charset=UTF-8
GuardBasic$reject_response(response, scope, ..., .datastore)
responseThe response object
scopeThe scope of the endpoint
...Ignored
.datastoreThe data storage from firesale
clone()The objects of this class are cloneable with this method.
GuardBasic$clone(deep = FALSE)
deepWhether to make a deep clone.
# Create a guard of dubious quality
basic <- GuardBasic$new(
validate = function(user, password) {
user == "thomas" && password == "pedersen"
},
user_info = function(user) {
new_user_info(
name_given = "Thomas",
name_middle = "Lin",
name_family = "Pedersen"
)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.