Sha256: faf5839adbde2d20772c182cc94c3c2af8c12686025b234c5b3fb94836cfde18
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
module Conjur module WebServer class Login attr_reader :sessionid def initialize(sessionid) @sessionid = sessionid end def call(env) if sessionid = token_valid?(env) env["rack.session"][:sessionid] = sessionid response = Rack::Response.new(env) configuration = { account: Conjur.configuration.account, stack: Conjur.configuration.stack, appliance_url: Conjur.configuration.appliance_url, login: Conjur::Authn.get_credentials[0] } response.status = 302 response.set_cookie('conjur_configuration', value: JSON.pretty_generate(configuration), path: '/') response['Location'] = "/ui" response.finish else [ 403, {}, ["Authorization is missing or invalid"] ] end end protected def token_valid?(env) token = extract_token(env) if token == sessionid sessionid else nil end end def extract_token(env) require 'cgi' require 'uri' query = URI.parse(env['REQUEST_URI']).query query && ( sessionid = CGI.parse(query)['sessionid'] ) && sessionid[0] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
conjur-asset-ui-api-1.1.1 | lib/conjur/webserver/login.rb |
conjur-asset-ui-api-1.1.0 | lib/conjur/webserver/login.rb |