-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for self-service profiles (#989)
* ss-sso files added * support dum,deploy for self-service-sso * unit test added yaml, directory * added e2e recordings * lint fix
- Loading branch information
1 parent
5ff0727
commit a13e794
Showing
21 changed files
with
14,898 additions
and
3,893 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import { constants } from '../../../tools'; | ||
import log from '../../../logger'; | ||
|
||
import { dumpJSON, existsMustBeDir, getFiles, loadJSON, sanitize } from '../../../utils'; | ||
import { DirectoryHandler } from '.'; | ||
import DirectoryContext from '..'; | ||
import { ParsedAsset } from '../../../types'; | ||
import { SsProfileWithCustomText } from '../../../tools/auth0/handlers/selfServiceProfiles'; | ||
|
||
type ParsedSelfServiceProfiles = ParsedAsset< | ||
'selfServiceProfiles', | ||
Partial<SsProfileWithCustomText>[] | ||
>; | ||
|
||
function parse(context: DirectoryContext): ParsedSelfServiceProfiles { | ||
const selfServiceProfilesFolder = path.join( | ||
context.filePath, | ||
constants.SELF_SERVICE_PROFILE_DIRECTORY | ||
); | ||
if (!existsMustBeDir(selfServiceProfilesFolder)) return { selfServiceProfiles: null }; // Skip | ||
|
||
const files = getFiles(selfServiceProfilesFolder, ['.json']); | ||
|
||
const selfServiceProfiles = files.map((f) => { | ||
const ssProfiles = { | ||
...loadJSON(f, { | ||
mappings: context.mappings, | ||
disableKeywordReplacement: context.disableKeywordReplacement, | ||
}), | ||
}; | ||
return ssProfiles; | ||
}); | ||
|
||
return { | ||
selfServiceProfiles, | ||
}; | ||
} | ||
|
||
async function dump(context: DirectoryContext): Promise<void> { | ||
const { selfServiceProfiles } = context.assets; | ||
if (!selfServiceProfiles) return; | ||
|
||
const selfServiceProfilesFolder = path.join( | ||
context.filePath, | ||
constants.SELF_SERVICE_PROFILE_DIRECTORY | ||
); | ||
fs.ensureDirSync(selfServiceProfilesFolder); | ||
|
||
selfServiceProfiles.forEach((profile) => { | ||
const ssProfileFile = path.join(selfServiceProfilesFolder, sanitize(`${profile.name}.json`)); | ||
log.info(`Writing ${ssProfileFile}`); | ||
|
||
if ('created_at' in profile) { | ||
delete profile.created_at; | ||
} | ||
|
||
if ('updated_at' in profile) { | ||
delete profile.updated_at; | ||
} | ||
|
||
dumpJSON(ssProfileFile, profile); | ||
}); | ||
} | ||
|
||
const emailProviderHandler: DirectoryHandler<ParsedSelfServiceProfiles> = { | ||
parse, | ||
dump, | ||
}; | ||
|
||
export default emailProviderHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { YAMLHandler } from '.'; | ||
import YAMLContext from '..'; | ||
import { ParsedAsset } from '../../../types'; | ||
import { SsProfileWithCustomText } from '../../../tools/auth0/handlers/selfServiceProfiles'; | ||
|
||
type ParsedSelfServiceProfiles = ParsedAsset< | ||
'selfServiceProfiles', | ||
Partial<SsProfileWithCustomText>[] | ||
>; | ||
|
||
async function parse(context: YAMLContext): Promise<ParsedSelfServiceProfiles> { | ||
const { selfServiceProfiles } = context.assets; | ||
|
||
if (!selfServiceProfiles) return { selfServiceProfiles: null }; | ||
|
||
return { | ||
selfServiceProfiles, | ||
}; | ||
} | ||
|
||
async function dump(context: YAMLContext): Promise<ParsedSelfServiceProfiles> { | ||
let { selfServiceProfiles } = context.assets; | ||
if (!selfServiceProfiles) return { selfServiceProfiles: null }; | ||
|
||
selfServiceProfiles = selfServiceProfiles.map((profile) => { | ||
if ('created_at' in profile) { | ||
delete profile.created_at; | ||
} | ||
|
||
if ('updated_at' in profile) { | ||
delete profile.updated_at; | ||
} | ||
|
||
return { | ||
...profile, | ||
}; | ||
}); | ||
|
||
return { | ||
selfServiceProfiles, | ||
}; | ||
} | ||
|
||
const selfServiceProfileHandler: YAMLHandler<ParsedSelfServiceProfiles> = { | ||
parse, | ||
dump, | ||
}; | ||
|
||
export default selfServiceProfileHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.