/usr/lib/ruby/1.8/oauth/server.rb is in liboauth-ruby1.8 0.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | require 'oauth/helper'
require 'oauth/consumer'
module OAuth
# This is mainly used to create consumer credentials and can pretty much be ignored if you want to create your own
class Server
include OAuth::Helper
attr_accessor :base_url
@@server_paths = {
:request_token_path => "/oauth/request_token",
:authorize_path => "/oauth/authorize",
:access_token_path => "/oauth/access_token"
}
# Create a new server instance
def initialize(base_url, paths = {})
@base_url = base_url
@paths = @@server_paths.merge(paths)
end
def generate_credentials
[generate_key(16), generate_key]
end
def generate_consumer_credentials(params = {})
Consumer.new(*generate_credentials)
end
# mainly for testing purposes
def create_consumer
creds = generate_credentials
Consumer.new(creds[0], creds[1],
{
:site => base_url,
:request_token_path => request_token_path,
:authorize_path => authorize_path,
:access_token_path => access_token_path
})
end
def request_token_path
@paths[:request_token_path]
end
def request_token_url
base_url + request_token_path
end
def authorize_path
@paths[:authorize_path]
end
def authorize_url
base_url + authorize_path
end
def access_token_path
@paths[:access_token_path]
end
def access_token_url
base_url + access_token_path
end
end
end
|