Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"provides": [
{
"id": "users-bl",
"version": "6.1",
"version": "7.0",
"handlers": [
{
"methods": ["GET"],
Expand Down Expand Up @@ -33,21 +33,6 @@
"inventory-storage.service-points.item.get"
]
},
{
"methods" : [ "POST" ],
"pathPattern" : "/bl-users/login",
"permissionsRequired" : [],
"modulePermissions" : [
"users.item.get",
"users.collection.get",
"perms.users.get",
"usergroups.item.get",
"inventory-storage.service-points-users.collection.get",
"inventory-storage.service-points-users.item.get",
"inventory-storage.service-points.collection.get",
"inventory-storage.service-points.item.get"
]
},
{
"methods" : [ "POST" ],
"pathPattern" : "/bl-users/login-with-expiry",
Expand Down Expand Up @@ -243,7 +228,7 @@
},
{
"id" : "login",
"version" : "7.3"
"version" : "8.0"
},
{
"id": "authtoken",
Expand Down
32 changes: 0 additions & 32 deletions ramls/mod-users-bl.raml
Original file line number Diff line number Diff line change
Expand Up @@ -186,38 +186,6 @@ resourceTypes:
type: { compositeOpenTransactionsResource: { "typeName" : "username" } }
/_self:
type: { compositeUserResource: { "typeName" : "self reference" } }
/login:
post:
description: Allow a new user to login and return an authtoken, along with a composite user record. Deprecated and will be removed in a future release. Please use /login-with-expiry.
is: [permissionsExpandable, includeable]
headers:
User-Agent:
X-Forwarded-For:
body:
application/json:
type: loginCredentials
responses:
201:
body:
application/json:
type: compositeUser
headers:
x-okapi-token:
400:
description: "Bad request"
body:
text/plain:
example: "Bad request"
422:
description: "Unprocessable Entity"
body:
application/json:
type: errors
500:
description: "Internal server error"
body:
text/plain:
example: "Internal server error"
/login-with-expiry:
post:
description: |
Expand Down
28 changes: 6 additions & 22 deletions src/main/java/org/folio/rest/impl/BLUsersAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public class BLUsersAPI implements BlUsers {
private static final String UNDEFINED_USER = "UNDEFINED_USER__";

private static final String LOGIN_ENDPOINT = "/authn/login-with-expiry";
private static final String LOGIN_ENDPOINT_LEGACY = "/authn/login";
private static final String FOLIO_ACCESS_TOKEN = "folioAccessToken";
private static final String SET_COOKIE_HEADER = "Set-Cookie";

Expand Down Expand Up @@ -853,14 +852,6 @@ public void postBlUsersLoginWithExpiry(boolean expandPerms, List<String> include
LOGIN_ENDPOINT, this::loginResponse);
}

@Override
public void postBlUsersLogin(boolean expandPerms, List<String> include, String userAgent, String xForwardedFor,
LoginCredentials entity, Map<String, String> okapiHeaders, Handler<AsyncResult<javax.ws.rs.core.Response>> asyncResultHandler,
Context vertxContext) {
doPostBlUsersLogin(expandPerms, include, userAgent, xForwardedFor, entity, okapiHeaders, asyncResultHandler,
LOGIN_ENDPOINT_LEGACY, this::loginResponseLegacy);
}

@SuppressWarnings("java:S1874")
private void doPostBlUsersLogin(boolean expandPerms, List<String> include, String userAgent, String xForwardedFor, //NOSONAR
LoginCredentials entity, Map<String, String> okapiHeaders, Handler<AsyncResult<javax.ws.rs.core.Response>> asyncResultHandler,
Expand All @@ -879,7 +870,7 @@ private void doPostBlUsersLogin(boolean expandPerms, List<String> include, Strin

if (entity == null || entity.getUsername() == null || entity.getPassword() == null) {
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond400WithTextPlain("Improperly formatted request")));
PostBlUsersLoginWithExpiryResponse.respond400WithTextPlain("Improperly formatted request")));
} else {
HttpClientInterface clientForLogin = HttpClientFactory.getHttpClient(okapiURL, okapiHeaders.get(OKAPI_TENANT_HEADER));
String moduleURL = "/authn/login";
Expand Down Expand Up @@ -913,21 +904,21 @@ private void doPostBlUsersLogin(boolean expandPerms, List<String> include, Strin
} catch (Exception e) {
client.closeClient();
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond500WithTextPlain(e.getLocalizedMessage())));
PostBlUsersLoginWithExpiryResponse.respond500WithTextPlain(e.getLocalizedMessage())));
} finally {
clientForLogin.closeClient();
}
})
.exceptionally(throwable -> {
clientForLogin.closeClient();
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond500WithTextPlain(throwable.getLocalizedMessage())));
PostBlUsersLoginWithExpiryResponse.respond500WithTextPlain(throwable.getLocalizedMessage())));
return null;
});
} catch (Exception ex) {
clientForLogin.closeClient();
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond500WithTextPlain(ex.getLocalizedMessage())));
PostBlUsersLoginWithExpiryResponse.respond500WithTextPlain(ex.getLocalizedMessage())));
}
}
}
Expand Down Expand Up @@ -999,7 +990,7 @@ okapiHeaders, null, handlePreviousResponse(false, false, false,
} catch (Exception ex) {
client.closeClient();
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond500WithTextPlain(ex.getLocalizedMessage())));
PostBlUsersLoginWithExpiryResponse.respond500WithTextPlain(ex.getLocalizedMessage())));
}
}
}
Expand Down Expand Up @@ -1084,7 +1075,7 @@ okapiHeaders, null, handlePreviousResponse(false, false, false,
} catch (Exception e) {
if(!aRequestHasFailed[0]){
asyncResultHandler.handle(Future.succeededFuture(
PostBlUsersLoginResponse.respond500WithTextPlain(e.getLocalizedMessage())));
PostBlUsersLoginWithExpiryResponse.respond500WithTextPlain(e.getLocalizedMessage())));
}
logger.error(e.getMessage(), e);
} finally {
Expand Down Expand Up @@ -1126,13 +1117,6 @@ private static void fillCompositeUserWithServicePoint(Map<String, CompletableFut
}
}

@SuppressWarnings("java:S1874")
private javax.ws.rs.core.Response loginResponseLegacy(Response loginResponse, CompositeUser cu) {
String token = String.valueOf(loginResponse.getHeaders().get(OKAPI_TOKEN_HEADER));
return PostBlUsersLoginResponse.respond201WithApplicationJson(cu,
PostBlUsersLoginResponse.headersFor201().withXOkapiToken(token));
}

@SuppressWarnings("java:S1874")
private javax.ws.rs.core.Response loginResponse(Response loginResponse, CompositeUser cu) {
JsonObject body = loginResponse.getBody();
Expand Down
Loading