Created
October 5, 2022 11:24
-
-
Save leoc/8c7b67f4324300645ad5fdd212d8e821 to your computer and use it in GitHub Desktop.
XML-RPC-TAN handler for hibiscus-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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