From 376c202396194f2df2db8c38076da2da644bb205 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 19 Nov 2015 15:00:20 -0500 Subject: [PATCH] LP#1468422 Internal auth service WIP Signed-off-by: Bill Erickson --- Open-ILS/examples/opensrf.xml.example | 32 +- Open-ILS/src/c-apps/oils_auth_internal.c | 998 +++++++++++++++++++++++++++++++ 2 files changed, 1024 insertions(+), 6 deletions(-) create mode 100644 Open-ILS/src/c-apps/oils_auth_internal.c diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 3b47481f86..241f1042bc 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -424,6 +424,29 @@ vim:et:ts=4:sw=4: + + 30 + 90 + 10 + + + + + + + 5 + 1 + c + oils_auth_internal.so + + 1000 + 1 + 15 + 1 + 5 + + + 420 @@ -431,13 +454,10 @@ vim:et:ts=4:sw=4: 300 2 weeks - - 30 - 90 - 10 - - + + + diff --git a/Open-ILS/src/c-apps/oils_auth_internal.c b/Open-ILS/src/c-apps/oils_auth_internal.c new file mode 100644 index 0000000000..c00df20cee --- /dev/null +++ b/Open-ILS/src/c-apps/oils_auth_internal.c @@ -0,0 +1,998 @@ +#include "opensrf/osrf_app_session.h" +#include "opensrf/osrf_application.h" +#include "opensrf/osrf_settings.h" +#include "opensrf/osrf_json.h" +#include "opensrf/log.h" +#include "openils/oils_utils.h" +#include "openils/oils_constants.h" +#include "openils/oils_event.h" + +#define OILS_AUTH_CACHE_PRFX "oils_auth_" +#define OILS_AUTH_COUNT_SFFX "_count" + +#define MODULENAME "open-ils.auth-internal" + +#define OILS_AUTH_OPAC "opac" +#define OILS_AUTH_STAFF "staff" +#define OILS_AUTH_TEMP "temp" +#define OILS_AUTH_PERSIST "persist" + +// Default time for extending a persistent session: ten minutes +#define DEFAULT_RESET_INTERVAL 10 * 60 + +int osrfAppInitialize(); +int osrfAppChildInit(); + +static long _oilsAuthOPACTimeout = 0; +static long _oilsAuthStaffTimeout = 0; +static long _oilsAuthOverrideTimeout = 0; +static long _oilsAuthPersistTimeout = 0; +static long _oilsAuthSeedTimeout = 0; +static long _oilsAuthBlockTimeout = 0; +static long _oilsAuthBlockCount = 0; + + +/** + @brief Initialize the application by registering functions for method calls. + @return Zero in all cases. +*/ +int osrfAppInitialize() { + + osrfLogInfo(OSRF_LOG_MARK, "Initializing Auth Internal Server..."); + + /* load and parse the IDL */ + if (!oilsInitIDL(NULL)) return 1; /* return non-zero to indicate error */ + + osrfAppRegisterMethod( + MODULENAME, + "open-ils.auth-internal.session.create", + "oilsAutInternalCreateSession", + "Adds a user to the authentication cache to indicate the user is authenticated" + " PARAMS( username )", 1, 0 ); + + osrfAppRegisterMethod( + MODULENAME, + "open-ils.auth.authenticate.complete", + "oilsAuthComplete", + "Completes the authentication process. Returns an object like so: " + "{authtoken : , authtime: