11 Replies Latest reply on Jul 13, 2012 12:31 AM by 25c49980-cb2e-4113-a5a7-2f0078c85330

    Rhoconnect Authenticate Method error information hidden

    25c49980-cb2e-4113-a5a7-2f0078c85330

      Folks,

       

      I've added some "interesting authentication" code to the authenticate method in application.rb.

       

      When all is well, it's no problem - but unlike source adapters, I don't seem to get any error or warning information in the Rhoconnect logs.

       

      If I cut and paste the code into an adapter query method and execute it, the errors/warnings/debug are there for all to see.

       

      Am I missing a setting, or is there anything I can do to change this?

       

      Any thoughts?

       

      Many Thanks

       

      John

        • Re: Rhoconnect Authenticate Method error information hidden

          If you return false from your authenticate method - then, the server will just return standard 401 error ("Not autheticated").

          However, if you will raise a LoginException in your code , then, server will return 401 error with the message from the exception. For example:

           

          def autheticate(login, password)

           

          # do something

            raise new RhoConnect::LoginException("This is my custom login exception!!!")

           

          end

           

          Max.

            • Re: Rhoconnect Authenticate Method error information hidden
              25c49980-cb2e-4113-a5a7-2f0078c85330

              Thanks for your advice.  It's useful to know.  It's not the problem I've been struggling with though - I'll try to be more precise.

               

              This is my 'example' authentication method:

               

              def authenticate(username,password,session)

               

                    success = false

               

                    # Create a service client object for the service calling as current user

                    authClient =  WCFService.new "AuthenticationService", username

               

                    # Call the service action on the service passing the userId parameter

                    response = authClient.request("Authenticate",{ "tem:userId" => username, "tem:password" => password })

               

                    response.include?("<result>true</result>")

               

                  end

               

               

              My issue is that if something in my WCFService class errors, I don't get to see the message.  Additionally, I don't get to see any of the debug output issued by Savon (which is called by my class WCFService).

               

              If I make the same call in a source adapter query method (just as a proof of concept) the debug and error information is included in the Rhoconnect logs.

               

              It makes debugging problems quite difficult and I wondered if it were a setting or if there were something I could do to ensure the output was captured.

               

              Thanks again

               

              John

                • Re: Rhoconnect Authenticate Method error information hidden

                  We do not use Savon, we use RestClient. However, if your service is using Savon, you can configure it to show the output and control the errors (unless your service reconfigures it after that).

                  Here is the docs:

                   

                  http://savonrb.com/#configuration

                   

                  Max.

                    • Re: Rhoconnect Authenticate Method error information hidden
                      25c49980-cb2e-4113-a5a7-2f0078c85330

                      Max,

                       

                      Thanks again this is again really useful. However reading the link you've included, logging is enabled by default - and this is what we experience when using it elsewhere (source adapter query methods for example).

                       

                      My real problem is that despite this logging being enabled, we DO NOT SEE that output when it's been called from the authentication method.  I presume it's being produced just not pushed into the log from the authentication method.  Perhaps this is by design?

                       

                      Thanks again

                       

                      John

                        • Re: Rhoconnect Authenticate Method error information hidden

                          I would think that the log is not being produced by your webservice.

                           

                          Max.

                            • Re: Rhoconnect Authenticate Method error information hidden
                              25c49980-cb2e-4113-a5a7-2f0078c85330

                              Thanks Max.

                               

                              However, the very same web service (in fact  the very same code cut and pasted) shows output when called from a query method rather from application.rb's authenticate method.

                               

                              Cheers

                               

                              John

                                • Re: Rhoconnect Authenticate Method error information hidden

                                  There are no restrictions on the log in any of the adapter methods. You can test this by inserting this into the  'authenticate' method and verify that it outputs the log:

                                   

                                  def authenticate(login, password)

                                       log "this is my log message"

                                   

                                       true

                                  end

                                    • Re: Rhoconnect Authenticate Method error information hidden
                                      25c49980-cb2e-4113-a5a7-2f0078c85330

                                      Thanks Max.

                                       

                                      I had already tried something similar, using p "My message" and found that to be working, in fact I initially used that for some rudimentary debugging.

                                       

                                      I wondered if it were something to do with 'stderr' - not knowing Ruby very well, that's the Unix/C analogy which may or may not apply.

                                       

                                      I'll knock up a simple, reproducible test case and post the exact method on here as soon as I get chance.  I should have done that initially really, but there's always a higher priority.

                                       

                                      Thanks again for your help.

                                       

                                      Cheers

                                       

                                      John

                                      • Re: Rhoconnect Authenticate Method error information hidden
                                        25c49980-cb2e-4113-a5a7-2f0078c85330

                                        Here we go.  A rather crude example that shows exactly what issue I'm having.

                                         

                                        def authenticate(username,password,session)

                                         

                                               log "Testing log"

                                               p "Testing p"

                                               $stderr.puts "Testing standard error directly"

                                               log "About to cause a divide by zero error to test automatic error redirection to log"

                                               p 1/0

                                               log "I'm back from causing the divide by zero error" #not expecting to see this message

                                         

                                               true

                                         

                                            end

                                        I change my authenticate method to the above and stop/start the thin server.

                                         

                                        tail thin.?.log

                                         

                                        ==> thin.0.log <==

                                        >> Writing PID to /var/run/thin/thin.0.pid

                                        >> Changing process privilege to rhoconnect:rhoconnect

                                        >> Using rack adapter

                                        [07:00:01 AM 2012-07-12] Rhoconnect Server v3.2.0 started...

                                        "Pushing lib directory..."

                                        >> Thin web server (v1.3.1 codename Triple Espresso)

                                        >> Maximum connections set to 1024

                                        >> Listening on /tmp/thin.0.sock, CTRL+C to stop

                                         

                                         

                                        ==> thin.1.log <==

                                        >> Writing PID to /var/run/thin/thin.1.pid

                                        >> Changing process privilege to rhoconnect:rhoconnect

                                        >> Using rack adapter

                                        [07:00:02 AM 2012-07-12] Rhoconnect Server v3.2.0 started...

                                        "Pushing lib directory..."

                                        >> Thin web server (v1.3.1 codename Triple Espresso)

                                        >> Maximum connections set to 1024

                                        >> Listening on /tmp/thin.1.sock, CTRL+C to stop

                                         

                                        The use Rhosimulator client to perform a log on (authenticate) against this server and re-check the logs...

                                         

                                        tail thin.?.log

                                         

                                        ==> thin.0.log <==

                                        [07:00:01 AM 2012-07-12] Rhoconnect Server v3.2.0 started...

                                        "Pushing lib directory..."

                                        >> Thin web server (v1.3.1 codename Triple Espresso)

                                        >> Maximum connections set to 1024

                                        >> Listening on /tmp/thin.0.sock, CTRL+C to stop

                                        [07:01:22 AM 2012-07-12] Use of the POST /application/clientlogin is deprecated. Use POST /api/application/clientlogin instead.

                                        [07:01:22 AM 2012-07-12] Testing log

                                        "Testing p"

                                        Testing standard error directly

                                        [07:01:22 AM 2012-07-12] About to cause a divide by zero error to test automatic error redirection to log

                                         

                                         

                                        ==> thin.1.log <==

                                        >> Listening on /tmp/thin.1.sock, CTRL+C to stop

                                        >> Exiting!

                                        >> Writing PID to /var/run/thin/thin.1.pid

                                        >> Changing process privilege to rhoconnect:rhoconnect

                                        >> Using rack adapter

                                        [07:00:02 AM 2012-07-12] Rhoconnect Server v3.2.0 started...

                                        "Pushing lib directory..."

                                        >> Thin web server (v1.3.1 codename Triple Espresso)

                                        >> Maximum connections set to 1024

                                        >> Listening on /tmp/thin.1.sock, CTRL+C to stop

                                         

                                        I put the same code at the top the query method in a test source adapter and change the authenticate method to a simple 'true' to allow me to log on.

                                        Again use the rhosimulator client to log on (this time successfully) and trigger a sync.  Examination of the relevant logfile this time shows the following:

                                         

                                         

                                         

                                        >> Writing PID to /var/run/thin/thin.0.pid

                                        >> Changing process privilege to rhoconnect:rhoconnect

                                        >> Using rack adapter

                                        [07:16:09 AM 2012-07-12] Rhoconnect Server v3.2.0 started...

                                        "Pushing lib directory..."

                                        >> Thin web server (v1.3.1 codename Triple Espresso)

                                        >> Maximum connections set to 1024

                                        >> Listening on /tmp/thin.0.sock, CTRL+C to stop

                                        [07:16:56 AM 2012-07-12] Use of the POST /application/clientlogin is deprecated. Use POST /api/application/clientlogin instead.

                                        [07:16:56 AM 2012-07-12] Use of the POST /application/clientregister is deprecated. Use POST /api/application/clientregister instead.

                                        [07:16:56 AM 2012-07-12] Use of the GET /application is deprecated. Use GET /api/application/query instead.

                                        [07:16:56 AM 2012-07-12] Testing log

                                        "Testing p"

                                        Testing standard error directly

                                        [07:16:56 AM 2012-07-12] About to cause a divide by zero error to test automatic error redirection to log

                                        [07:16:56 AM 2012-07-12] SourceAdapter raised query exception: divided by 0

                                        [07:16:56 AM 2012-07-12] /var/www/rhoconnect/sources/attr_dom_values.rb:22:in `/'

                                        /var/www/rhoconnect/sources/attr_dom_values.rb:22:in `query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_adapter.rb:82:in `do_query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:417:in `_read'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:57:in `read'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:96:in `block (2 levels) in do_query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/stats/record.rb:54:in `update'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:94:in `block in do_query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source.rb:283:in `if_need_refresh'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:93:in `do_query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/source_sync.rb:87:in `process_query'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/client_sync.rb:37:in `send_cud'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/api/application/query.rb:4:in `block (2 levels) in <top (required)>'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `block in catch_all'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `catch'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `catch_all'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/api/application/query.rb:2:in `block in <top (required)>'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:56:in `block (2 levels) in execute_api_call'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `block in catch_all'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `catch'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:41:in `catch_all'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/rhoconnect-3.2.0/lib/rhoconnect/async.rb:55:in `block in execute_api_call'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:1012:in `call'

                                        /opt/rhoconnect/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:1012:in `block in spawn_threadpool'

                                         

                                        Whilst I'm certain I didn't need to I've emboldened the big difference showing what I'd like to be seeing coming out of the authenticate method.  I was just hoping (and there may well be) something I can do along the lines of Unix "2>&1" to send standard error to the same place as standard out.

                                         

                                        Again, many thanks - your time and insights are much appreciated.

                                         

                                        John