Generate the Authorization header value from the supplied options:
335556
function genAuthorizationHeaderValue (options) {

    log(options.verbose,"Now generating Authorization header value ...");

    var authHeaderParams = [];

    authHeaderParams.push(createEncodedParam("oauth_consumer_key",options.oAuthConsumerKey));
    authHeaderParams.push(createEncodedParam("oauth_nonce",options.oAuthNonce));
    authHeaderParams.push(createEncodedParam("oauth_signature",options.oAuthSignature));
    authHeaderParams.push(createEncodedParam("oauth_signature_method",options.oAuthSignatureMethod));
    authHeaderParams.push(createEncodedParam("oauth_timestamp",options.oAuthTimestamp));
    authHeaderParams.push(createEncodedParam("oauth_token",options.oAuthToken));
    authHeaderParams.push(createEncodedParam("oauth_version",options.oAuthVersion));

    var authHeaderValue = "OAuth ";

    log(options.verbose,"Authorization header key/value pairs are:");

    for ( var i=0; i<authHeaderParams.length; i++ ) {
        log(options.verbose,"  "+authHeaderParams[i].key+"=\""+authHeaderParams[i].value+"\"");
        authHeaderValue += authHeaderParams[i].key+"=\""+authHeaderParams[i].value+"\"";
        if ( authHeaderParams[i+1] ) {
            authHeaderValue += ", ";
        }
    }

    log(options.verbose,"Authorization header value is: "+authHeaderValue);

    return authHeaderValue;
}
687487
def api_token_header(options, path = nil)
      return nil if path == '/j_security_check'
      unless @api_token
        fail Error::MissingCredentials, 'Please set a api_token for user'
      end
      options[:headers] = {} if options[:headers].nil?
      options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token)
    end
1353478
function Headers(options) {
  if (!(this instanceof Headers))
    return new Headers(options);

  AbstractBlock.call(this);

  if (options)
    this.parseOptions(options);
}
409728
def _security_auth_headers(self, username, password, headers):
        
        userColonPassword = username + ":" + password
        b64UserColonPassword = base64. \
            b64encode(str_to_bytes(userColonPassword)).decode("ascii")
        headers['Authorization'] = 'Basic %s' % b64UserColonPassword
391280
function __process_authorization_header_for_client(request_params) {
    return new Promise(async (resolve, reject) => {
        try {
            const client_account_id = await client_endpoint
                .client_registrar_module
                .get_client_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password);

            return resolve(request_params);
        } catch (err) {
            return reject(new Error("Unauthorized request"));
        }
    });
}
747942
def to_header(self):
        """"""
        d = dict(self)
        auth_type = d.pop("__auth_type__", None) or "basic"
        return "%s %s" % (
            auth_type.title(),
            ", ".join(
                [
                    "%s=%s"
                    % (
                        key,
                        quote_header_value(
                            value, allow_token=key not in self._require_quoting
                        ),
                    )
                    for key, value in iteritems(d)
                ]
            ),
        )
676518
def create_authorization_response(self, uri, http_method='GET', body=None,
                                      headers=None, scopes=None, credentials=None):
        """"""
        request = Request(
            uri, http_method=http_method, body=body, headers=headers)
        request.scopes = scopes
        # TODO: decide whether this should be a required argument
        request.user = None     # TODO: explain this in docs
        for k, v in (credentials or {}).items():
            setattr(request, k, v)
        response_type_handler = self.response_types.get(
            request.response_type, self.default_response_type_handler)
        log.debug('Dispatching response_type %s request to %r.',
                  request.response_type, response_type_handler)
        return response_type_handler.create_authorization_response(
            request, self.default_token_type)
881300
function (options) {
        /**
         * The header Key
         * @type {String}
         * @todo avoid headers with falsy key.
         */
        this.key = _.get(options, 'key') || E;

        /**
         * The header value
         * @type {String}
         */
        this.value = _.get(options, 'value') || E;

        /**
         * Indicates whether the header was added by internal SDK operations, such as authorizing a request.
         * @type {*|boolean}
         */
        _.has(options, 'system') && (this.system = options.system);

        /**
         * Indicates whether the header should be .
         * @type {*|boolean}
         * @todo figure out whether this should be in property.js
         */
        _.has(options, 'disabled') && (this.disabled = options.disabled);
    }
81180
def options(self, *args, **kwargs):
        """"""
        self.enable_cache()
        self.handle_session_cookie()
        self.preflight()

        if self.verify_origin():
            allowed_methods = getattr(self, 'access_methods', 'OPTIONS, POST')
            self.set_header('Access-Control-Allow-Methods', allowed_methods)
            self.set_header('Allow', allowed_methods)

            self.set_status(204)
        else:
            # Set forbidden
            self.set_status(403)

        self.finish()
1089352
def parse_authorization_header(value, charset='utf-8'):
    '''
    '''
    if not value:
        return
    try:
        auth_type, auth_info = value.split(None, 1)
        auth_type = auth_type.lower()
    except ValueError:
        return
    if auth_type == 'basic':
        try:
            up = b64decode(auth_info.encode(CHARSET)).decode(charset)
            username, password = up.split(':', 1)
        except Exception:
            return
        return BasicAuth(username, password)
    elif auth_type == 'digest':
        auth_map = parse_dict_header(auth_info)
        if not digest_parameters.difference(auth_map):
            return DigestAuth(auth_map.pop('username'), options=auth_map)
21328
function adminAcl(options) {
  var opts = options || {};

  if (!opts.secret) {
    throw new Error('missing secret');
  }

  var expectedHeader;
  if (opts.prefix) {
    expectedHeader = opts.prefix + ' ' + opts.secret;
  }
  else {
    expectedHeader = module.exports.DEFAULT_PREFIX + opts.secret;
  }

  return function (req, res, next) {
    debug('inside of the middleware headerCheck');

    var msg401 = { success: false, message: 'Unauthorized' };

    if (!req.headers) {
      debug('no headers found - misconfiguration probably');
      return res.status(401).send(msg401);
    }
    
    if (!req.headers.authorization) {
      debug('no authorization header found');
      return res.status(401).send(msg401);
    }

    debug('we have a token it seems');
    var receivedHeader = req.headers.authorization;

    if (secureCompare(receivedHeader, expectedHeader)) {
      next();
    }
    else {
      debug('failed on secret match');
      return res.status(401).send(msg401);
    }
  };
}
721601
public function before_request(&$url, &$headers, &$data, &$type, &$options)
    {
        $headers['Authorization'] = 'Basic '.base64_encode($this->token.':'.$this->key);
    }
906561
def token(self):
        '''
        '''
        auth_header = self.headers.get('Authorization', '')
        if 'Token ' in auth_header:
            return auth_header.partition('Token ')[-1]
        else:
            return auth_header
515235
def transform_api_header_authorization(param, value):
    """"""
    try:
        username, password = value.split(":", 1)
    except ValueError:
        raise click.BadParameter(
            "Authorization header needs to be Authorization=username:password",
            param=param,
        )

    value = "%s:%s" % (username.strip(), password)
    value = base64.b64encode(bytes(value.encode()))
    return "Basic %s" % value.decode("utf-8")
216531
def gen_cors_headers(opts)
      headers = []

      allow_credentials = opts[:access_control_allow_credentials]
      if allow_credentials
        allow_credentials = allow_credentials.to_s
        raise ArgumentError unless allow_credentials == 'true' ||
                                   allow_credentials == 'false'
        headers.push([ 'Access-Control-Allow-Credentials', allow_credentials ])
      end

      allow_headers = opts[:access_control_allow_headers]
      if allow_headers
        raise ArgumentError unless allow_headers =~ CORS_HEADERS_REGEX
        allow_headers = allow_headers.split(', ').map(&:downcase).sort.join(', ')
        headers.push([ 'Access-Control-Allow-Headers', allow_headers ])
      end

      allow_methods = opts[:access_control_allow_methods]
      if allow_methods
        raise ArgumentError unless allow_methods.kind_of? String

        unknown_methods = allow_methods.split(', ').reject do |str|
                            CORS_METHODS.include? str
                          end
        raise ArgumentError unless unknown_methods.size == 0

        headers.push([ 'Access-Control-Allow-Methods', allow_methods ])
      end

      allow_origin = opts[:access_control_allow_origin]
      if allow_origin
        raise ArgumentError unless allow_origin.kind_of? String
        raise ArgumentError unless allow_origin == '*' ||
                                   allow_origin == 'null' ||
                                   allow_origin =~ CORS_ORIGIN_REGEX
        headers.push([ 'Access-Control-Allow-Origin', allow_origin ])
      end

      expose_headers = opts[:access_control_expose_headers]
      if expose_headers
        raise ArgumentError unless expose_headers =~ CORS_HEADERS_REGEX
        expose_headers = expose_headers.split(', ').map(&:downcase).sort.join(', ')
        headers.push([ 'Access-Control-Expose-Headers', expose_headers ])
      end

      max_age = opts[:access_control_max_age]
      if max_age
        raise ArgumentError unless max_age.kind_of?(Integer) && max_age >= 0
        headers.push([ 'Access-Control-Max-Age', max_age.to_s ])
      end

      headers
    end
878543
def parse_authorization_header(auth_header):
    
    if len(auth_header) > MAX_LENGTH:
        raise BadHeaderValue('Header exceeds maximum length of {max_length}'.format(
            max_length=MAX_LENGTH))

    # Make sure we have a unicode object for consistency.
    if isinstance(auth_header, six.binary_type):
        auth_header = auth_header.decode('utf8')

    scheme, attributes_string = auth_header.split(' ', 1)

    if scheme.lower() != 'hawk':
        raise HawkFail("Unknown scheme '{scheme}' when parsing header"
                       .format(scheme=scheme))


    attributes = {}

    def replace_attribute(match):
        """Extract the next key="value"-pair in the header."""
        key = match.group('key')
        value = match.group('value')
        if key not in allowable_header_keys:
            raise HawkFail("Unknown Hawk key '{key}' when parsing header"
                           .format(key=key))
        validate_header_attr(value, name=key)
        if key in attributes:
            raise BadHeaderValue('Duplicate key in header: {key}'.format(key=key))
        attributes[key] = value

    # Iterate over all the key="value"-pairs in the header, replace them with
    # an empty string, and store the extracted attribute in the attributes
    # dict. Correctly formed headers will then leave nothing unparsed ('').
    unparsed_header = HAWK_HEADER_RE.sub(replace_attribute, attributes_string)
    if unparsed_header != '':
        raise BadHeaderValue("Couldn't parse Hawk header", unparsed_header)

    log.debug('parsed Hawk header: {header} into: \n{parsed}'
              .format(header=auth_header, parsed=pprint.pformat(attributes)))
    return attributes
608534
def authorization_header(self):
        
        return 'Basic %s' % base64.b64encode(bytes(self.username + ':' + self.password, 'ascii')).decode('ascii')