use of org.owasp.oag.config.configuration.LoginProvider in project Application-Gateway by gianlucafrei.
the class WiremockTest method makeLogin.
protected LoginResult makeLogin() {
try {
// ACT1: Start the login
var loginResult = webClient.get().uri("/auth/local/login").exchange().expectStatus().isFound().returnResult(String.class);
var redirectUriString = loginResult.getResponseHeaders().getFirst("Location");
URI redirectUri = new URI(redirectUriString);
AuthenticationRequest oidcRequest = AuthenticationRequest.parse(redirectUri);
LoginProvider provider = config.getLoginProviders().get("local");
assertTrue(redirectUriString.startsWith((String) provider.getWith().get("authEndpoint")));
assertEquals(provider.getWith().get("clientId"), oidcRequest.getClientID().toString());
var loginStateCookie = loginResult.getResponseCookies().getFirst(LoginStateCookie.NAME);
// ACT 2: Call the callback url
// Arrange
String authorizationResponse = String.format("?state=%s&code=%s", oidcRequest.getState().getValue(), "authCode");
var callbackResult = webClient.get().uri("/auth/local/callback" + authorizationResponse).cookie(loginStateCookie.getName(), loginStateCookie.getValue()).exchange().expectStatus().isFound().returnResult(String.class);
var result = new LoginResult(callbackResult);
// id from jwt token
result.id = "248289761001";
return result;
} catch (Exception e) {
throw new ApplicationException("Login Failed", e);
}
}
use of org.owasp.oag.config.configuration.LoginProvider in project Application-Gateway by gianlucafrei.
the class LoginProvidorValidationTest method testNoFields.
@Test
public void testNoFields() {
// Arrange
LoginProvider provider = new LoginProvider(null, null);
// Act
var errors = provider.getErrors(context);
// Assert
assertEquals(2, errors.size());
}
use of org.owasp.oag.config.configuration.LoginProvider in project Application-Gateway by gianlucafrei.
the class LoginController method loadLoginDriver.
public LoginDriver loadLoginDriver(String providerKey) {
// Load settings
LoginProvider provider = loadProvider(providerKey);
String driverName = provider.getType();
try {
return loginDriverFactory.loadDriverByKey(driverName, provider.getWith());
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "could not find login driver", e);
}
}
use of org.owasp.oag.config.configuration.LoginProvider in project Application-Gateway by gianlucafrei.
the class LoginProvidorValidationTest method testInvalidProviderName.
@Test
public void testInvalidProviderName() {
// Arrange
LoginProvider provider = new LoginProvider("doesnotexist", new LoginProviderSettings());
// Act
var errors = provider.getErrors(context);
// Assert
assertEquals(1, errors.size());
}
use of org.owasp.oag.config.configuration.LoginProvider in project Application-Gateway by gianlucafrei.
the class LoginProvidorValidationTest method testInvalidInvalidSettings.
@Test
public void testInvalidInvalidSettings() {
// Arrange
LoginProvider provider = new LoginProvider("oidc", new LoginProviderSettings());
// Act
var errors = provider.getErrors(context);
// Assert
assertTrue(!errors.isEmpty(), "Expected errors with invalid configuration");
}
Aggregations