Sha256: 016178956d62621e95cb1224002c0ba4ab528f0f5f1ff4bfd8f6dad48ce12957

Contents?: true

Size: 1.16 KB

Versions: 56

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

56 entries across 56 versions & 1 rubygems

Version Path
hephaestus-0.8.16.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.16 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15.5 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15.4 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15.3 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.15 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.14 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.13 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.12.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.12.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.12 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.11 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.10 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.9.2 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.9.1 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.9 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.8 app/controllers/hephaestus/application_controller.rb
hephaestus-0.8.7.5 app/controllers/hephaestus/application_controller.rb