mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 05:27:48 +00:00
feat(user-auth): use ms library and update docs
This commit is contained in:
@@ -1,29 +1,16 @@
|
|||||||
|
import ms, { StringValue } from "ms";
|
||||||
|
|
||||||
const convertToMilliseconds = (exp: string | number): number => {
|
const convertToMilliseconds = (exp: string | number): number => {
|
||||||
if (typeof exp === "number") {
|
if (typeof exp === "number") {
|
||||||
return exp * 1000;
|
return exp * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = exp.match(/^(\d+)\s*([a-z]*)$/i);
|
const result = ms(exp as StringValue);
|
||||||
if (!match) {
|
if (typeof result !== "number") {
|
||||||
throw new Error(`Invalid expiration format: ${exp}`);
|
throw new Error(`Invalid expiration format: ${exp}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = parseInt(match[1], 10);
|
return result;
|
||||||
const unit = match[2].toLowerCase();
|
|
||||||
|
|
||||||
switch (unit) {
|
|
||||||
case "":
|
|
||||||
case "s":
|
|
||||||
return value * 1000; // seconds
|
|
||||||
case "m":
|
|
||||||
return value * 60 * 1000; // minutes
|
|
||||||
case "h":
|
|
||||||
return value * 60 * 60 * 1000; // hours
|
|
||||||
case "d":
|
|
||||||
return value * 24 * 60 * 60 * 1000; // days
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported time unit: ${unit}`);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMinExpiresIn = (exp1: string | number, exp2: string | number): string | number => {
|
export const getMinExpiresIn = (exp1: string | number, exp2: string | number): string | number => {
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ The **Settings** page lets you manage information about your organization includ
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
You can adjust the maximum time a user token will remain valid for your organization. After this period, users will be required to re-authenticate. This helps improve security by enforcing regular sign-ins.
|
||||||
|
</Tip>
|
||||||
|
|
||||||
## Access Control
|
## Access Control
|
||||||
|
|
||||||
The **Access Control** page is where you can manage identities (both people and machines) that are part of your organization.
|
The **Access Control** page is where you can manage identities (both people and machines) that are part of your organization.
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 519 KiB After Width: | Height: | Size: 352 KiB |
Reference in New Issue
Block a user