feat: support new auth methods for Tenants

- New Time scalar type is implemented on the Server
- Single Sign-On keys can now be generated
- Single Sign-On keys can be regenerated
- Single Sign-On keys now store the date they were generated on.
- Initial implementation of `AuthenticationTargetFilter`'s
This commit is contained in:
Wyatt Johnson
2018-10-19 16:05:58 -06:00
parent 9436600e31
commit fa72d5deda
9 changed files with 249 additions and 5 deletions
+22
View File
@@ -5,6 +5,7 @@ import { GQLSettingsInput } from "talk-server/graph/tenant/schema/__generated__/
import {
createTenant,
CreateTenantInput,
regenerateTenantSSOKey,
Tenant,
updateTenant,
} from "talk-server/models/tenant";
@@ -76,3 +77,24 @@ export async function canInstall(cache: TenantCache) {
export async function isInstalled(cache: TenantCache) {
return (await cache.count()) > 0;
}
/**
* regenerateSSOKey will regenerate the Single Sign-On key for the specified
* Tenant and notify all other Tenant's connected that the Tenant was updated.
*/
export async function regenerateSSOKey(
mongo: Db,
redis: Redis,
cache: TenantCache,
tenant: Tenant
) {
const updatedTenant = await regenerateTenantSSOKey(mongo, tenant.id);
if (!updatedTenant) {
return null;
}
// Update the tenant cache.
await cache.update(redis, updatedTenant);
return updatedTenant;
}