Sha256: 8f6aaeabc8ac561b00e96e12dd5fdd3853ab7ea744cbbc7dd634c9d8b026c398

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true
module Masks
  module OpenID
    class TokensController < ApplicationController
      rescue_from Rack::OAuth2::Server::Authorize::BadRequest do |e|
        @error = e

        render :error, status: e.status
      end

      def new
        authorize
      end

      def create
        authorize approved: params[:approve]
      end

      private

      def authorize(**opts)
        # TODO: support incoming id_token request object + max_age parameter
        @authorization = Authorization.perform(request.env, **opts)

        unless @authorization.actor
          session[:return_to] = request.url

          return redirect_to session_path
        end

        _status, header, = @authorization.response

        if header["WWW-Authenticate"].present?
          headers["WWW-Authenticate"] = header["WWW-Authenticate"]
        end

        if header["Location"]
          redirect_to header["Location"]
        else
          render :new
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
masks-0.4.0 app/controllers/masks/openid/tokens_controller.rb