Sha256: 016178956d62621e95cb1224002c0ba4ab528f0f5f1ff4bfd8f6dad48ce12957

Contents?: true

Size: 1.16 KB

Versions: 57

Compression:

Stored size: 1.16 KB

Contents

# typed: false
# frozen_string_literal: true

require "opentelemetry-semantic_conventions"

module Hephaestus
  class ApplicationController < ActionController::Base
    include ActionController::MimeResponds

    include Hephaestus::Headers
    include Hephaestus::Responses

    rescue_from ActionController::UnknownFormat, with: :not_acceptable
    protect_from_forgery with: :null_session

    def ensure_json_request
      return if request.format.json?

      not_acceptable
    end

    # Yetto sends a unique state parameter as part of the OAuth installation process.
    # This decodes that into something the plug can use.
    def parse_state(state)
      decoded_state = Base64.urlsafe_decode64(state)
      state = JSON.parse(decoded_state)

      {
        version: state["version"],
        salt: state["salt"],
        nonce: state["nonce"] || "",
        plug_installation_id: state["plug_installation_id"],
        membership_id: state["membership_id"], # optional, used for conversation.viewed events
        redirect_to: state["redirect_to"],
      }
    rescue ArgumentError # invalid base64
      {}
    rescue JSON::ParserError # invalid JSON
      {}
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
hephaestus-0.8.7.5 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7.4 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7.3 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.6 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.5 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.4.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.4 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.3.4 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.3.3 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.3.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.3.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.3 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.0 app/controllers/hephaestus/application_controller.rb
hephaestus-0.7.7.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.7.7 app/controllers/hephaestus/application_controller.rb