<@U04UQ68083H> should I serve the login page as we...
# ory-copilot
q
@chilly-king-10285 should I serve the login page as well if I don't have a login challenge from hydra. Is it considered a best practice?
b
A message from kapa.ai
According to the Ory Hydra documentation, the login challenge is a crucial part of the authentication process. When an OAuth 2.0 Flow is initiated, Ory Hydra asks the login provider to authenticate the subject and then inform the Ory OAuth2 Service about it. The authentication challenge is appended to the login provider URL to which the subject's user-agent (browser) is redirected to. The login provider uses that challenge to fetch information on the OAuth2 request and then accept or reject the requested authentication process. If you don't have a login challenge from Hydra, it means that an OAuth 2.0 Flow has not been initiated, and therefore, there is no need to serve the login page. It's not a matter of best practice, but rather a requirement of the OAuth 2.0 Flow. However, if you have a login challenge and the
remember_me
parameter is not set in the
accept login request
, the login challenge will always instruct you to show the login UI. If the
remember_me
parameter is set, Hydra will keep track of the session and you won't need to show the login UI again for the same session. In conclusion, you should only serve the login page when you have a login challenge from Hydra, and whether you need to serve it again for the same session depends on the
remember_me
parameter. Sources: - [Hydra won't remember my login](https://www.ory.sh/docs/hydra/faq#hydra-wont-remember-my-login) - [Get OAuth 2.0 Login Request](https://www.ory.sh/docs/hydra/reference/api)
q
@chilly-king-10285 what do you think is best to show the user when the login page is visited without the login challenge?
b
A message from kapa.ai
If a user visits the login page without a login challenge, it means that an OAuth 2.0 Flow has not been initiated. In this case, it might be best to redirect the user to a default page or show a message indicating that they are not part of an active authentication process. You could also provide options for the user to initiate a new login process, or provide information on how to do so. This could be a button that says "Start Login Process" which redirects to the appropriate endpoint to initiate the OAuth 2.0 Flow, or instructions on how to initiate the process. Remember, the exact implementation would depend on the specifics of your application and user needs. It's important to provide clear and helpful feedback to the user in any scenario. Please note that this is a general suggestion and the exact implementation might vary based on your application's specific requirements and user experience design.