Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic MFA needed for Hydra with Kratos #3637

Open
5 tasks done
andremussche opened this issue Sep 28, 2023 · 3 comments
Open
5 tasks done

Dynamic MFA needed for Hydra with Kratos #3637

andremussche opened this issue Sep 28, 2023 · 3 comments
Labels
feat New feature or request.

Comments

@andremussche
Copy link

andremussche commented Sep 28, 2023

Preflight checklist

Ory Network Project

No response

Describe your problem

For a new project (dutch education) we need to enforce a 2FA check when the user wants to do something special (e.g. some admin functionality or view gpdr data). So normally the user logs in with e.g. Office365 via Kratos and gets access (via Hydra based on ID Token) but on some parts in the application we need to dynamically ask for a MFA (e.g. totp).

I can retrieve the "amr" values in the ID Token when the user has done an AAL2 login somehow, so that's not the problem:

  • "amr": ["oidc","totp"]

I tried different kind of extra parameters to the "auth" call, like "acr_values=2", "aal=aal2":

But these params are not handled, so the Kratos redirect stays the same (no "aal" value):

Describe your ideal solution

The workaround (see below) feels weird of course: is there an other/better way to do this?

Or can Hydra be extended with a "acr_values" parameter:

Or with "amr_values" likes Microsoft:

Or maybe pass the "aal=aal2" parameter to Kratos?

Workarounds or alternatives

The only way I could get it working (locally) was using 2 Hydra instances:

  1. a normal one, with normal config:
urls:
  self:
    issuer: http://localhost:4444
  consent: http://localhost:4455/consent
  login: http://localhost:4455/login
  1. and a second one, using the same Hydra database and connected to the same Kratos instance, but with an extra AAL login parameter:
serve:
  admin:
    port: 4442  # different port than default 4445
  public:
    port: 4443 # different port than default 4444

urls:
  self:
    issuer: http://localhost:4443
  consent: http://localhost:4455/consent
  login: http://localhost:4455/login?aal=aal2   # enforce 2FA!

So the application initially requests an ID token using Hydra#1 and when the user wants to do some admin stuff it will request an ID token using Hydra#2 (and checks the "amr" claim of the JWT).

Version

oryd/hydra:v2.2

Additional Context

No response

@andremussche andremussche added the feat New feature or request. label Sep 28, 2023
@andremussche
Copy link
Author

Maybe this is an option too: instead of a separate instance, make it configurable per client: #3205

@vinckr
Copy link
Member

vinckr commented Sep 29, 2023

Have you seen this: https://www.ory.sh/docs/kratos/mfa/step-up-authentication

Maybe your use case would be much easier if you leave out the OAuth2 part.

What is the reason to involve Hydra? IMHO OAuth2 is overkill for most projects.

Assume we know nothing about what you are trying to do, only thing we know is that you are building a new project in education.

@andremussche
Copy link
Author

@vinckr Yes I know :).
We will use Kratos as a "federation" hub and the user should be able to choose between Office365 (teachers or employees of our customer), our own legacy IDP and 2 educational OIDC providers (students) so we have one single "identity" server. Our customer has several (external) web apps which needs an identity on a standardized way so they choose OIDC with PKCE.
AFAIK Kratos can connect with OIDC providers but we need Hydra so others can connect to us using OIDC?
For another project, we use Kratos + oauthkeeper but there we have internal apps (behind the api gateway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants