Search code examples
authenticationazure-active-directoryopenid-connectory

Ory / Kratos Login page for Login with Microsoft?


I am trying to use Ory Kratos and have users login with their existing Microsoft account. After completing the guide at https://www.ory.sh/kratos/docs/concepts/credentials/openid-connect-oidc-oauth2 I cannot get it to work.

My question is what login url the flow should return? If it is left empty, then a page is displayed saying that this configuration should be set:

selfservice:
  flows:
    login:
      ui_url: http://my-app.com/login

But I want the user to be presented with Microsoft's login form, and then be redirected back when the user is logged in. I don't want to present a custom login form asking for microsoft credentials.

How should the login flow be configured when using Kratos and Microsoft login flow?


Solution

  • Like you mentioned it is mandatory to specify a ui_url. So, what you could do try is just hide the default ID, Password and Submit sections of the UI and display only the Sign in with Microsoft button.

    So the Signin flow becomes more or less like the following: enter image description here

    That's what I did in my reference implementation that I tried by following the documentation here: https://www.ory.sh/kratos/docs/guides/sign-in-with-github-google-facebook-linkedin/#microsoft

    The link to my reference implementation: https://github.com/atreya2011/go-kratos-test/tree/microsoft-oidc

    Although my reference implementation is in Go, you can adapt it to any other language of your choice!

    The config file details are here: https://github.com/atreya2011/go-kratos-test/tree/microsoft-oidc/config

    To try out the reference implementation, you need to have Docker installed and then do the following:

    1. Clone the repository locally.
    2. Run docker-compose up --build
    3. Then in your browser, open, http://localhost:4455/login

    Don't forget to update the config with your client_id and client_secret that you got from Microsoft!

    Hope my answer was helpful :)