Search code examples
ruby-on-railsomniauth

How the omniauth gem create the routes?


I am using the omniauth to implement the authentication strategy, but there is one thing I cannot understand: The omniauth would generate some routes to use but I cannot see it by rake routes.

For example, the gem omniauth-saml will generate the auth/saml routes, when I visit this path, It will initiate the request phase. However, I cannot find it on the routes list. Therefore, it's hard for me to know which routes have already been created and could be used directly.

Could anyone help me?

Cheers


Solution

  • I have found the answer.

    Omniauth is a rack based application, so it can handle every HTTP request and do the tasks based on different path. They call the task phase.

    It includes two mainly phases:

    request phase: Default path is "#{path_prefix}/#{name}"

    callback phase: Default path is "#{path_prefix}/#{name}/callback, customise by options[:callback_path]