Class: RubyCoded::Auth::OAuthCallbackServer
- Inherits:
-
Object
- Object
- RubyCoded::Auth::OAuthCallbackServer
- Defined in:
- lib/ruby_coded/auth/oauth_callback_server.rb
Overview
This class is used to start a local webrick server for the OAuth authentication callback
Constant Summary collapse
- PORT =
1_455- TIMEOUT =
120
Instance Method Summary collapse
-
#initialize ⇒ OAuthCallbackServer
constructor
A new instance of OAuthCallbackServer.
- #shutdown ⇒ Object
- #start ⇒ Object
- #wait_for_callback ⇒ Object
Constructor Details
#initialize ⇒ OAuthCallbackServer
Returns a new instance of OAuthCallbackServer.
16 17 18 19 20 |
# File 'lib/ruby_coded/auth/oauth_callback_server.rb', line 16 def initialize @result_queue = Queue.new @server = WEBrick::HTTPServer.new(Port: PORT, Logger: WEBrick::Log.new(File::NULL), AccessLog: []) @server.mount "/auth/callback", CallbackServlet, @result_queue end |
Instance Method Details
#shutdown ⇒ Object
32 33 34 35 |
# File 'lib/ruby_coded/auth/oauth_callback_server.rb', line 32 def shutdown @server.shutdown @thread&.join(5) end |
#start ⇒ Object
22 23 24 |
# File 'lib/ruby_coded/auth/oauth_callback_server.rb', line 22 def start @thread = Thread.new { @server.start } end |
#wait_for_callback ⇒ Object
26 27 28 29 30 |
# File 'lib/ruby_coded/auth/oauth_callback_server.rb', line 26 def wait_for_callback Timeout.timeout(TIMEOUT) { @result_queue.pop } ensure shutdown end |