module Terjira::Client::AuthOptionBuilder
Constants
- AUTH_CACHE_KEY
Public Instance Methods
auth_file_cache()
click to toggle source
# File lib/terjira/client/auth_option_builder.rb, line 57 def auth_file_cache @auth_file_cache ||= Terjira::FileCache.new('profile') end
build_auth_options(options = {})
click to toggle source
# File lib/terjira/client/auth_option_builder.rb, line 9 def build_auth_options(options = {}) cache_key = options[:cache_key] || AUTH_CACHE_KEY auth_file_cache.fetch cache_key do build_auth_options_by_tty(options) end end
build_auth_options_by_cached(options = {})
click to toggle source
# File lib/terjira/client/auth_option_builder.rb, line 16 def build_auth_options_by_cached(options = {}) cache_key = options[:cache_key] || AUTH_CACHE_KEY auth_file_cache.get(cache_key) end
build_auth_options_by_tty(options = {})
click to toggle source
# File lib/terjira/client/auth_option_builder.rb, line 25 def build_auth_options_by_tty(options = {}) puts 'Login will be required...' prompt = TTY::Prompt.new result = prompt.collect do key(:site).ask('Site (ex: https://myjira.atlassian.net):', required: true) key(:context_path).ask('Jira path in your site (just press enter if you don\'t have):', default: '') key(:username).ask('Username:', required: true) key(:password).mask('Password (Server) / API Token (Cloud):', required: true) if options['ssl-config'] key(:use_ssl).yes?('Use SSL?') key(:ssl_verify_mode).select('Verify mode:') do |menu| menu.choice 'Verify peer', OpenSSL::SSL::VERIFY_PEER menu.choice 'Verify client once', OpenSSL::SSL::VERIFY_CLIENT_ONCE menu.choice 'Verify fail if no peer cert', OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT menu.choice 'Verify none', OpenSSL::SSL::VERIFY_NONE end end if options['proxy-config'] key(:proxy_address).ask("Proxy address: ", default: nil) key(:proxy_port).ask("Proxy port: ", default: nil) end end result[:auth_type] = :basic result[:use_ssl] ||= false if result[:site] =~ /http\:\/\// result end
expire_auth_options()
click to toggle source
# File lib/terjira/client/auth_option_builder.rb, line 21 def expire_auth_options Terjira::FileCache.clear_all end