Module: Katello::Authentication::ClientAuthentication
- Included in:
- Api::Rhsm::CandlepinProxiesController
- Defined in:
- app/services/katello/authentication/client_authentication.rb
Instance Method Summary collapse
- #add_candlepin_version_header ⇒ Object
- #authenticate_client ⇒ Object
-
#cert_from_request ⇒ Object
HTTP_X_RHSM_SSL_CLIENT_CERT - custom client cert header typically coming from a reverse proxy on a Capsule passing RHSM traffic through in isolation HTTP_SSL_CLIENT_CERT - standard client cert header coming from direct interactions with the server.
- #cert_present? ⇒ Boolean
- #set_client_user ⇒ Object
Instance Method Details
#add_candlepin_version_header ⇒ Object
41 42 43 |
# File 'app/services/katello/authentication/client_authentication.rb', line 41 def add_candlepin_version_header response.headers["X-CANDLEPIN-VERSION"] = "katello/#{Katello::VERSION}" end |
#authenticate_client ⇒ Object
7 8 9 10 |
# File 'app/services/katello/authentication/client_authentication.rb', line 7 def authenticate_client set_client_user User.current.present? end |
#cert_from_request ⇒ Object
HTTP_X_RHSM_SSL_CLIENT_CERT - custom client cert header typically coming from a reverse
proxy on a Capsule passing RHSM traffic through in isolation
HTTP_SSL_CLIENT_CERT - standard client cert header coming from direct interactions with the
server
32 33 34 35 36 37 38 39 |
# File 'app/services/katello/authentication/client_authentication.rb', line 32 def cert_from_request request.env['HTTP_X_RHSM_SSL_CLIENT_CERT'] || request.env['SSL_CLIENT_CERT'] || request.env['HTTP_SSL_CLIENT_CERT'] || ENV['HTTP_X_RHSM_SSL_CLIENT_CERT'] || ENV['SSL_CLIENT_CERT'] || ENV['HTTP_SSL_CLIENT_CERT'] end |
#cert_present? ⇒ Boolean
23 24 25 26 |
# File 'app/services/katello/authentication/client_authentication.rb', line 23 def cert_present? ssl_client_cert = cert_from_request !ssl_client_cert.nil? && !ssl_client_cert.empty? && ssl_client_cert != "(null)" end |
#set_client_user ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/katello/authentication/client_authentication.rb', line 12 def set_client_user if cert_present? client_cert = ::Cert::RhsmClient.new(cert_from_request) uuid = client_cert.uuid User.current = CpConsumerUser.new do |cp_consumer| cp_consumer.uuid = uuid cp_consumer.login = uuid end end end |