@roadiehq/catalog-backend-module-okta
Version:
A set of Backstage catalog providers for Okta
60 lines (56 loc) • 1.59 kB
JavaScript
;
var oktaSdkNodejs = require('@okta/okta-sdk-nodejs');
var catalogModel = require('@backstage/catalog-model');
class OktaEntityProvider {
account;
logger;
connection;
constructor(account, options) {
this.account = account;
this.logger = options.logger;
}
getClient(orgUrl, oauthScopes = void 0) {
const account = this.account;
if (account.oauth && oauthScopes) {
const { clientId, privateKey, keyId } = account.oauth;
return new oktaSdkNodejs.Client({
orgUrl,
authorizationMode: "PrivateKey",
clientId,
scopes: oauthScopes,
privateKey,
keyId
});
} else if (account.token) {
return new oktaSdkNodejs.Client({
orgUrl,
token: account.token
});
}
throw new Error(
`accountConfig for ${orgUrl} missing api token or oath key`
);
}
async connect(connection) {
this.connection = connection;
}
async buildDefaultAnnotations() {
return {
[catalogModel.ANNOTATION_LOCATION]: this.getProviderName(),
[catalogModel.ANNOTATION_ORIGIN_LOCATION]: this.getProviderName()
};
}
getCustomAnnotations(member, allowList) {
const profileAnnotations = {};
if (allowList.length) {
for (const [key, value] of new Map(Object.entries(member.profile))) {
if (allowList.includes(key)) {
profileAnnotations[key] = value.toString();
}
}
}
return profileAnnotations;
}
}
exports.OktaEntityProvider = OktaEntityProvider;
//# sourceMappingURL=OktaEntityProvider.cjs.js.map