Search in sources :

Example 1 with MFAEnrollStep

use of io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep in project gravitee-access-management by gravitee-io.

the class AuthenticationFlowHandlerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    List<AuthenticationFlowStep> steps = new LinkedList<>();
    steps.add(new MFAEnrollStep(RedirectHandler.create("/mfa/enroll"), ruleEngine, factorManager));
    steps.add(new MFAChallengeStep(RedirectHandler.create("/mfa/challenge"), ruleEngine, factorManager));
    AuthenticationFlowChainHandler authenticationFlowChainHandler = new AuthenticationFlowChainHandler(steps);
    when(jwtService.encode(any(JWT.class), (CertificateProvider) eq(null))).thenReturn(Single.just("token"));
    Factor factor = new Factor();
    factor.setFactorType(FactorType.SMS);
    when(factorManager.getFactor(anyString())).thenReturn(factor);
    router.route("/login").order(Integer.MIN_VALUE).handler(new CookieSessionHandler(jwtService, certificateManager, userService, "am-cookie", 30 * 60 * 60));
    router.route("/login").handler(authenticationFlowChainHandler).handler(rc -> rc.response().setStatusCode(200).end()).failureHandler(new ErrorHandler());
}
Also used : FactorType(io.gravitee.am.common.factor.FactorType) Factor(io.gravitee.am.model.Factor) MFASettings(io.gravitee.am.model.MFASettings) ArgumentMatchers(org.mockito.ArgumentMatchers) MFAChallengeStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAChallengeStep) Client(io.gravitee.am.model.oidc.Client) AuthenticationFlowChainHandler(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowChainHandler) Mock(org.mockito.Mock) UserService(io.gravitee.am.service.UserService) RunWith(org.junit.runner.RunWith) ConstantKeys(io.gravitee.am.common.utils.ConstantKeys) Single(io.reactivex.Single) RememberDeviceSettings(io.gravitee.am.model.RememberDeviceSettings) HttpStatusCode(io.gravitee.common.http.HttpStatusCode) EnrolledFactor(io.gravitee.am.model.factor.EnrolledFactor) JWTService(io.gravitee.am.gateway.handler.common.jwt.JWTService) User(io.gravitee.am.gateway.handler.common.vertx.web.auth.user.User) RxWebTestBase(io.gravitee.am.gateway.handler.common.vertx.RxWebTestBase) JsonObject(io.vertx.core.json.JsonObject) LinkedList(java.util.LinkedList) SpELRuleEngine(io.gravitee.am.gateway.handler.common.ruleengine.SpELRuleEngine) JWT(io.gravitee.am.common.jwt.JWT) CertificateManager(io.gravitee.am.gateway.handler.common.certificate.CertificateManager) AuthenticationFlowStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowStep) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DEVICE_ALREADY_EXISTS_KEY(io.gravitee.am.common.utils.ConstantKeys.DEVICE_ALREADY_EXISTS_KEY) List(java.util.List) HttpMethod(io.vertx.core.http.HttpMethod) CertificateProvider(io.gravitee.am.gateway.certificate.CertificateProvider) MFAEnrollStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep) CookieSessionHandler(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.CookieSessionHandler) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Collections(java.util.Collections) FactorManager(io.gravitee.am.gateway.handler.common.factor.FactorManager) MFAChallengeStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAChallengeStep) MFAEnrollStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep) AuthenticationFlowStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowStep) JWT(io.gravitee.am.common.jwt.JWT) Factor(io.gravitee.am.model.Factor) EnrolledFactor(io.gravitee.am.model.factor.EnrolledFactor) AuthenticationFlowChainHandler(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowChainHandler) CookieSessionHandler(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.CookieSessionHandler) LinkedList(java.util.LinkedList)

Example 2 with MFAEnrollStep

use of io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep in project gravitee-access-management by gravitee-io.

the class AuthenticationFlowHandlerImpl method create.

@Override
public Handler<RoutingContext> create() {
    List<AuthenticationFlowStep> steps = new LinkedList<>();
    steps.add(new SPNEGOStep(RedirectHandler.create("/login/SSO/SPNEGO"), identityProviderManager));
    steps.add(new FormIdentifierFirstLoginStep(RedirectHandler.create("/login/identifier"), domain));
    steps.add(new FormLoginStep(RedirectHandler.create("/login")));
    steps.add(new WebAuthnRegisterStep(domain, RedirectHandler.create("/webauthn/register")));
    steps.add(new MFAEnrollStep(RedirectHandler.create("/mfa/enroll"), ruleEngine, factorManager));
    steps.add(new MFAChallengeStep(RedirectHandler.create("/mfa/challenge"), ruleEngine, factorManager));
    return new AuthenticationFlowChainHandler(steps);
}
Also used : MFAChallengeStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAChallengeStep) MFAEnrollStep(io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep) LinkedList(java.util.LinkedList)

Aggregations

MFAChallengeStep (io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAChallengeStep)2 MFAEnrollStep (io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.mfa.MFAEnrollStep)2 LinkedList (java.util.LinkedList)2 FactorType (io.gravitee.am.common.factor.FactorType)1 JWT (io.gravitee.am.common.jwt.JWT)1 ConstantKeys (io.gravitee.am.common.utils.ConstantKeys)1 DEVICE_ALREADY_EXISTS_KEY (io.gravitee.am.common.utils.ConstantKeys.DEVICE_ALREADY_EXISTS_KEY)1 CertificateProvider (io.gravitee.am.gateway.certificate.CertificateProvider)1 CertificateManager (io.gravitee.am.gateway.handler.common.certificate.CertificateManager)1 FactorManager (io.gravitee.am.gateway.handler.common.factor.FactorManager)1 JWTService (io.gravitee.am.gateway.handler.common.jwt.JWTService)1 SpELRuleEngine (io.gravitee.am.gateway.handler.common.ruleengine.SpELRuleEngine)1 RxWebTestBase (io.gravitee.am.gateway.handler.common.vertx.RxWebTestBase)1 User (io.gravitee.am.gateway.handler.common.vertx.web.auth.user.User)1 CookieSessionHandler (io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.CookieSessionHandler)1 AuthenticationFlowChainHandler (io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowChainHandler)1 AuthenticationFlowStep (io.gravitee.am.gateway.handler.common.vertx.web.handler.impl.internal.AuthenticationFlowStep)1 Factor (io.gravitee.am.model.Factor)1 MFASettings (io.gravitee.am.model.MFASettings)1 RememberDeviceSettings (io.gravitee.am.model.RememberDeviceSettings)1