GatewayFilter and json

26 views
Skip to first unread message

stefano....@gmail.com

unread,
Aug 28, 2013, 7:00:02 AM8/28/13
to rubycas...@googlegroups.com
Hi,

I successfully setup rubycas server along with some cassified application (I'm using last rubycas server e client gems with ruby 1.9.3 and rails 3). One app is using gatewayfilter to filter requests, everything works fine except for json format. After some debugging I come across to this code in filter.rb:

          def unauthorized!(controller, vr = nil)
            format = nil
            unless controller.request.format.nil?
              format = controller.request.format.to_sym
            end
            format = (format == :js ? :json : format)
            case format
            when :xml, :json
              if vr
                case format
                when :xml
                  controller.send(:render, :xml => { :error => vr.failure_message }.to_xml(:root => 'errors'), :status => :unauthorized)
                when :json
                  controller.send(:render, :json => { :errors => { :error => vr.failure_message }}, :status => :unauthorized)
                end
              else
                controller.send(:head, :unauthorized)
              end
            else
              redirect_to_cas_for_authentication(controller)
            end
          end

I don't understand why json and xml are special. Probably I'm doing something wrong ...

Thanks,

Stefano

Robert Mitwicki

unread,
Sep 3, 2013, 4:26:01 AM9/3/13
to rubycas...@googlegroups.com
Hi,

But what problem do you have with this code? When you request for json you get error or just wrong data? Please provide some additional information about error which you get.

Thanks
Best regards


--
You received this message because you are subscribed to the Google Groups "RubyCAS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubycas-serve...@googlegroups.com.
To post to this group, send email to rubycas...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubycas-server.
For more options, visit https://groups.google.com/groups/opt_out.



--
Robert Mitwicki
Senior Software Engineer
FXI Technologies

stefano....@gmail.com

unread,
Sep 18, 2013, 7:27:45 AM9/18/13
to rubycas...@googlegroups.com
Probably the problem is just me not understanding the way CAS should work.

Anyway I have a rails application with CAS enabled and working, when I request HTML everything works, when I request JSON the response is always 401 unauthorized. Searching the net I found similar problems and the solution was to bypass CAS filter for JSON and XML requests. Indeed these formats seem to have a special path in the code.

Thanks,

Stefano
Reply all
Reply to author
Forward
0 new messages