OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
swagger-ui-5.17.14
/
src
/
core
/
plugins
/
auth
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:11 AM
rwxr-xr-x
📄
actions.js
7.98 KB
08/07/2024 04:34:06 AM
rw-r--r--
📁
components
-
08/07/2024 04:34:34 AM
rwxr-xr-x
📁
configs-extensions
-
08/07/2024 04:34:34 AM
rwxr-xr-x
📄
index.js
2.33 KB
08/07/2024 04:34:06 AM
rw-r--r--
📄
reducers.js
1.97 KB
08/07/2024 04:34:06 AM
rw-r--r--
📄
selectors.js
3.11 KB
08/07/2024 04:34:06 AM
rw-r--r--
📁
spec-extensions
-
08/07/2024 04:34:34 AM
rwxr-xr-x
📄
wrap-actions.js
1.76 KB
08/07/2024 04:34:06 AM
rw-r--r--
Editing: wrap-actions.js
Close
/** * @prettier */ /** * `authorize` and `logout` wrapped actions provide capacity * to persist cookie based apiKey in document.cookie. * * `persistAuthorization` SwaggerUI options needs to set to `true` * for document.cookie persistence to work. */ export const authorize = (oriAction, system) => (payload) => { oriAction(payload) const configs = system.getConfigs() if (!configs.persistAuthorization) return // create cookie try { const [{ schema, value }] = Object.values(payload) const isApiKeyAuth = schema.get("type") === "apiKey" const isInCookie = schema.get("in") === "cookie" const isApiKeyInCookie = isApiKeyAuth && isInCookie if (isApiKeyInCookie) { document.cookie = `${schema.get("name")}=${value}; SameSite=None; Secure` } } catch (error) { console.error( "Error persisting cookie based apiKey in document.cookie.", error ) } } export const logout = (oriAction, system) => (payload) => { const configs = system.getConfigs() const authorized = system.authSelectors.authorized() // deleting cookie try { if (configs.persistAuthorization && Array.isArray(payload)) { payload.forEach((authorizedName) => { const auth = authorized.get(authorizedName, {}) const isApiKeyAuth = auth.getIn(["schema", "type"]) === "apiKey" const isInCookie = auth.getIn(["schema", "in"]) === "cookie" const isApiKeyInCookie = isApiKeyAuth && isInCookie if (isApiKeyInCookie) { const cookieName = auth.getIn(["schema", "name"]) document.cookie = `${cookieName}=; Max-Age=-99999999` } }) } } catch (error) { console.error( "Error deleting cookie based apiKey from document.cookie.", error ) } oriAction(payload) }