-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property 'httpAuth' does not exist on type 'PluginEnvironment'. #100
Comments
Which plugin version are you using? These 2 types you're mentioning have been added in some of the latest releases. In the latest, at least, I can tell that they are part of the type If the case is that your environment doesn't have such fields (which I guess that's the root cause) I would suggest 2 things:
const { auth, httpAuth } = createLegacyAuthAdapters(env);
const { router } = await S3Builder.createBuilder({
...env,
auth,
httpAuth,
}).build(); This is what the plugin does in the new backend system, and it has been working so far. If that fixes the issue, I could update the documentation so others using the old backend setup don't have the same issue |
I'm using the old backend and have not yet moved to a new backend setup. The solution you have provided, could you please guide me exactly where I should add it? I have tried to add these in type.ts and index.ts but still didn't work out. export type PluginEnvironment = { |
You should have to add it in your The line mentioned above is coming from the tutorial in backstage: https://backstage.io/docs/tutorials/auth-service-migration |
Although you have suggested a new backend system as a solution, the old backend system is still having problems. The auth and httpAuth methods that you are utilizing in S3Environment are incompatible with the old backend. I appreciate your response. |
What about doing this. I've just tested it in my local backstage: Extend your environment: // in packages/backend/src/types.ts
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import {
AuthService,
DatabaseService,
DiscoveryService,
HttpAuthService,
TokenManagerService,
UrlReaderService,
} from '@backstage/backend-plugin-api';
import { PluginTaskScheduler } from '@backstage/backend-tasks';
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
import { IdentityApi } from '@backstage/plugin-auth-node';
import { PluginCacheManager } from '@backstage/backend-common';
export type PluginEnvironment = {
auth?: AuthService; // add this optional
httpAuth?: HttpAuthService; // add this optional
logger: Logger;
database: DatabaseService;
cache: PluginCacheManager;
config: Config;
reader: UrlReaderService;
discovery: DiscoveryService;
tokenManager: TokenManagerService;
scheduler: PluginTaskScheduler;
permissions: PermissionEvaluator;
identity: IdentityApi;
}; Define your plugin: // in packages/backend/src/plugins/s3.ts
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import { PluginEnvironment } from '../types';
import { S3Builder } from '@spreadshirt/backstage-plugin-s3-viewer-backend';
import { Router } from 'express';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
const { auth, httpAuth } = createLegacyAuthAdapters(env);
const { router } = await S3Builder.createBuilder({
...env,
auth,
httpAuth,
}).build();
return router;
} |
Thank you for providing the solution. It functions. |
I believe this might be an issue with backstage itself. I was just checking the release notes from the version 1.27.0, and found out a change about the Anyways, just to double check, have you added the needed code to make the permissions work? That's what is explained here: https://github.com/spreadshirt/backstage-plugin-s3/tree/main/plugins/s3-viewer-backend#permissions-setup |
Thanks. I'll try to add the permission code; possibly, this will function after that. |
Getting an error when I added s3.ts file in backstage/packages/backend/scr/plugins.
import { S3Builder } from '@spreadshirt/backstage-plugin-s3-viewer-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
export default async function createPlugin(
env: PluginEnvironment,
): Promise {
const { router } = await S3Builder.createBuilder({
auth: env.auth,
config: env.config,
logger: env.logger,
scheduler: env.scheduler,
discovery: env.discovery,
permissions: env.permissions,
httpAuth: env.httpAuth,
}).build();
return router;
}
The text was updated successfully, but these errors were encountered: