An internal function which attempts to (hackily) reuse the upstream OAuth
signer.
554500
protected function sendCustomOauthPostRequest($uri, array $config)
    {
        // this method is hacky. it'd be easier if Oauth1 let you sign a one-off request
        $guzzle = $this->client->getGuzzle();

        $request = $guzzle->createRequest(
            'POST',
            $uri,
            [
                'auth' => null,
            ]
        );

        $oauth = $this->authentication->createOauth($config);

        $request->getConfig()->set('auth', 'oauth');

        $oauth->onBefore(
            new BeforeEvent(
                new Transaction(
                    $guzzle,
                    $request
                )
            )
        );

        $request->getConfig()->set('auth', null);

        return $guzzle->send($request);
    }
76076
def oauth2callback(self, view_func):
        

        @wraps(view_func)
        def decorated(*args, **kwargs):
            params = {}

            # Check sig
            if 'state' in request.args:
                params.update(**self.parse_state(request.args.get('state')))
                if params.pop('sig', None) != make_secure_token(**params):
                    return self.login_manager.unauthorized()

            code = request.args.get('code')

            # Web server flow
            if code:
                token = self.exchange_code(
                    code,
                    url_for(
                        request.endpoint,
                        _external=True,
                        _scheme=self.redirect_scheme,
                    ),
                )
                userinfo = self.get_userinfo(token['access_token'])
                params.update(token=token, userinfo=userinfo)

            # Browser flow
            else:
                if params:
                    params.update(dict(request.args.items()))
                else:
                    return '''
                    <script>
                      window.onload = function() {
                        location.href = '?' + window.location.hash.substr(1);
                      };
                    </script>
                    '''

            return view_func(**params)

        return decorated
1067693
def oauth_required(f):
        
        @wraps(f)
        def decorated_function(*args, **kwargs):
            if 'oauth_user_uri' not in session or session['oauth_user_uri'] is None:
                return redirect(url_for('.r_oauth_login', next=request.url))
            return f(*args,**kwargs)
        return decorated_function
678288
function OAuth2Strategy (provider, client, verify) {
  Strategy.call(this)
  this.provider = provider
  this.endpoints = provider.endpoints
  this.mapping = provider.mapping
  this.client = client
  this.name = provider.id
  this.verify = verify
}
925263
def digest_auth(realm, auth_func):
    
    def digest_auth_decorator(func):
        def func_replacement(self, *args, **kwargs):
            # 'self' here is the RequestHandler object, which is inheriting
            # from DigestAuthMixin to get 'get_authenticated_user'
            if self.get_authenticated_user(auth_func, realm):
                return func(self, *args, **kwargs)
        return func_replacement
    return digest_auth_decorator
578054
def requires_auth(func):
    
    @six.wraps(func)
    def wrapper(self, *args, **kwargs):
        if self.token_expired:
            self.authenticate()
        return func(self, *args, **kwargs)
    return wrapper
98662
function genOAuthSig (options) {

    log(options.verbose,"Now generating OAuth sig ...");

    // Build an array of all the parameters we need to include in the signature.
    // Signature parameters are in the format {key,value}, both the key and the
    // value need to be RFC3986 percent encoded.

    var sigParams  = [];

    if ( options.queryParams ) {
        Object.keys(options.queryParams).forEach(function (key) {
            sigParams.push(createEncodedParam(key,options.queryParams[key]));
        });
    }

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

    // Parameters need to be sorted alphabetically based on the encoded key.

    sigParams.sort(function (a,b) {
        if ( a.key < b.key ) {
            return -1;
        } else if ( a.key > b.key ) {
            return 1;
        } else {
            return 0;
        }
    });

    // Build the signature parameter string from the sorted array.

    var sigParamsString = "";

    log(options.verbose,"Ordered percent encoded sig params are:");

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

    log(options.verbose,"Generated sig params string: "+sigParamsString);

    // Build the base signature string from the HTTP method, base URL and signature
    // parameter string.

    var sigBaseString = options.method.toUpperCase()+"&";
    sigBaseString += percentEncode(options.baseURL)+"&";
    sigBaseString += percentEncode(sigParamsString);

    log(options.verbose,"Generated base sig string: "+sigBaseString);

    // Generate the signing key from the consumer secret and oAuth token secret.

    var signingKey = options.oAuthConsumerSecret+"&"+options.oAuthTokenSecret;

    log(options.verbose,"Generated HMAC-SHA1 signing key: "+signingKey);

    // The final value for the OAuth signature is the HMAC-SHA1 hash of the
    // signing key and the base sig string, all base64 encoded.

    var oAuthSig = crypto.createHmac("sha1",signingKey).update(sigBaseString).digest("base64");

    log(options.verbose,"OAuth sig is: "+oAuthSig);

    return oAuthSig;
}
564173
function signIn (defOptions, credentials, callback) {
  var promise = normalizeRequestParameters(defaults, 'SignIn', credentials).then(function (credentials) {

    var options = {
      method : 'POST',
      uri : 'v1/SignIn',
      json : credentials
    };
    
    extend(true, options, defOptions);
    
    return options;
    
  }).then(request).nodeify(callback);
  
  return promise;
}
213010
def authorize_from_request(rtoken, rsecret, verifier_or_pin)
      request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
      access_token = request_token.get_access_token(:oauth_verifier => verifier_or_pin)
      @atoken, @asecret = access_token.token, access_token.secret
    end
1176802
function createAssigner(keysFunc, defaults) {
        return function(obj) {
          var length = arguments.length;
          if (defaults) obj = Object(obj);  
          if (length < 2 || obj == null) return obj;
          for (var index = 1; index < length; index++) {
            var source = arguments[index],
                keys = keysFunc(source),
                l = keys.length;
            for (var i = 0; i < l; i++) {
              var key = keys[i];
              if (!defaults || obj[key] === void 0) obj[key] = source[key];
            }
          }
          return obj;
       };
    }
1207385
function(callback) {
        if (!res.parsedHeader.signature) {
          callback('unsigned');
        } else {
          var signVerifier = new Crypter({
            cert: res.session.cert
          });
          if (signVerifier.verifySignature(JSON.stringify(res.parsedHeader.content), res.parsedHeader.signature)) {
            callback(null);
          } else {
            callback('forgery');
          }
        }
      }
1037521
def put(self, source, rel_path, metadata=None):
        """"""
        return self.upstreams[0].put(source, rel_path, metadata)
658263
def make_signature(signer_func, data_to_sign, public_algo,
                   hashed_subpackets, unhashed_subpackets, sig_type=0):
    """"""
    # pylint: disable=too-many-arguments
    header = struct.pack('>BBBB',
                         4,         # version
                         sig_type,  # rfc4880 (section-5.2.1)
                         public_algo,
                         8)         # hash_alg (SHA256)
    hashed = subpackets(*hashed_subpackets)
    unhashed = subpackets(*unhashed_subpackets)
    tail = b'\x04\xff' + struct.pack('>L', len(header) + len(hashed))
    data_to_hash = data_to_sign + header + hashed + tail

    log.debug('hashing %d bytes', len(data_to_hash))
    digest = hashlib.sha256(data_to_hash).digest()
    log.debug('signing digest: %s', util.hexlify(digest))
    params = signer_func(digest=digest)
    sig = b''.join(mpi(p) for p in params)

    return bytes(header + hashed + unhashed +
                 digest[:2] +  # used for decoder's sanity check
                 sig)
749463
def requires_rw(f):
    
    @wraps(f)

    def decorated(*args, **kwargs):
        auth = args[1]
        if auth.readonly:
            logger = logging.getLogger()
            logger.info("read-only user '%s' is not authorized to run function '%s'" % (auth.username, f.__name__))
            raise authlib.AuthorizationFailed("read-only user '%s' is not authorized to run function '%s'" % (auth.username, f.__name__))
        return f(*args, **kwargs)

    return decorated
433140
def finalize_oauth(self, access_token, access_token_secret):
        
        self.access_token = access_token
        self.access_token_secret = access_token_secret

        # Final OAuth object
        self.oauth = OAuth1(
            self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.access_token,
            resource_owner_secret=self.access_token_secret)
680758
function authorizedHandler(value) {
    if (! value) return value;

    delete value.public_id;
    delete value.version;
    delete value.signature;
    delete value.resource_type;

    return value;
}
121448
def sign(uri, headers, credentials):
    
    consumer_key, token_key, token_secret = credentials
    auth = OAuthSigner(token_key, token_secret, consumer_key, "")
    auth.sign_request(uri, method="GET", body=None, headers=headers)