break identity client into an interface
The interface has changed a little instead of allowing the client to parse out the authorization header, it takes the request object as is to extract the identity from it how the implementation decides. IdentityClient#authenticate is now deprecated, in favor of IdentityApi#getIdentity. I am leaving the IdentityClient in place deprecated so that plugins that use this can migrate away from it. Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -59,6 +59,7 @@ import jenkins from './plugins/jenkins';
|
||||
import permission from './plugins/permission';
|
||||
import { PluginEnvironment } from './types';
|
||||
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
|
||||
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
|
||||
|
||||
function makeCreateEnv(config: Config) {
|
||||
const root = getRootLogger();
|
||||
@@ -72,6 +73,11 @@ function makeCreateEnv(config: Config) {
|
||||
const databaseManager = DatabaseManager.fromConfig(config);
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
const taskScheduler = TaskScheduler.fromConfig(config);
|
||||
const identity = DefaultIdentityClient.create({
|
||||
discovery,
|
||||
algorithms: undefined,
|
||||
issuer: undefined,
|
||||
});
|
||||
|
||||
root.info(`Created UrlReader ${reader}`);
|
||||
|
||||
@@ -80,6 +86,7 @@ function makeCreateEnv(config: Config) {
|
||||
const database = databaseManager.forPlugin(plugin);
|
||||
const cache = cacheManager.forPlugin(plugin);
|
||||
const scheduler = taskScheduler.forPlugin(plugin);
|
||||
|
||||
return {
|
||||
logger,
|
||||
cache,
|
||||
@@ -90,6 +97,7 @@ function makeCreateEnv(config: Config) {
|
||||
tokenManager,
|
||||
permissions,
|
||||
scheduler,
|
||||
identity,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { IdentityClient } from '@backstage/plugin-auth-node';
|
||||
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
|
||||
import { createRouter } from '@backstage/plugin-permission-backend';
|
||||
import {
|
||||
AuthorizeResult,
|
||||
@@ -40,7 +40,7 @@ export default async function createPlugin(
|
||||
logger: env.logger,
|
||||
discovery: env.discovery,
|
||||
policy: new AllowAllPermissionPolicy(),
|
||||
identity: IdentityClient.create({
|
||||
identity: DefaultIdentityClient.create({
|
||||
discovery: env.discovery,
|
||||
issuer: await env.discovery.getExternalBaseUrl('auth'),
|
||||
}),
|
||||
|
||||
@@ -32,5 +32,6 @@ export default async function createPlugin(
|
||||
database: env.database,
|
||||
catalogClient: catalogClient,
|
||||
reader: env.reader,
|
||||
identity: env.identity,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
PermissionAuthorizer,
|
||||
PermissionEvaluator,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import { IdentityApi } from '@backstage/plugin-auth-node';
|
||||
|
||||
export type PluginEnvironment = {
|
||||
logger: Logger;
|
||||
@@ -39,4 +40,5 @@ export type PluginEnvironment = {
|
||||
tokenManager: TokenManager;
|
||||
permissions: PermissionEvaluator | PermissionAuthorizer;
|
||||
scheduler: PluginTaskScheduler;
|
||||
identity: IdentityApi;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user