Skip to content

Instantly share code, notes, and snippets.

@leoc
Created October 5, 2022 11:24
Show Gist options
  • Save leoc/8c7b67f4324300645ad5fdd212d8e821 to your computer and use it in GitHub Desktop.
Save leoc/8c7b67f4324300645ad5fdd212d8e821 to your computer and use it in GitHub Desktop.
XML-RPC-TAN handler for hibiscus-server
# copy to: config.ru
# install gems: rack rack-rpc xmlrpc byebug awesome_print
# run: rackup -o 0.0.0.0 -p 3000 config.ru
require 'builder'
require 'rack/rpc'
require 'awesome_print'
require 'byebug'
require 'base64'
class Server < Rack::RPC::Server
def get_tan(prompt, account_id, tan_type, payload)
ap [prompt, account_id, tan_type]
meta, encoded = payload.split(",")
File.open('tan_request.png', 'wb') { |f| f.write(Base64.decode64(encoded)) }
puts "File saved to tan_request.png. Use PhotoTanApp and type TAN here:"
tan = gets.chomp
return tan
end
rpc 'hibiscus.getTan' => :get_tan
end
class MyApplication
def call(env)
[200, {"Content-Type" => "text/plain"}, ["Connection successful!"]]
end
end
use Rack::RPC::Endpoint, Server.new
run MyApplication.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment