Skip to content

Commit

Permalink
feat: drop generic envelop auth plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Oct 22, 2024
1 parent bf2b274 commit fbbdc3d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 61 deletions.
11 changes: 3 additions & 8 deletions packages/services/api/src/modules/auth/providers/auth-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CONTEXT, Inject, Injectable, Scope } from 'graphql-modules';
import type { RegistryContext } from '../../../context';
import { Injectable, Scope } from 'graphql-modules';
import type { User } from '../../../shared/entities';
import { AccessError } from '../../../shared/errors';
import type { Listify, MapToArray } from '../../../shared/helpers';
Expand Down Expand Up @@ -45,19 +44,15 @@ export interface TargetAccessSelector {
global: true,
})
export class AuthManager {
private session: Session;

constructor(
@Inject(CONTEXT) context: RegistryContext,
private organizationAccess: OrganizationAccess,
private projectAccess: ProjectAccess,
private targetAccess: TargetAccess,
private userManager: UserManager,
private tokenStorage: TokenStorage,
private storage: Storage,
) {
this.session = context.session;
}
private session: Session,
) {}

async ensureTargetAccess(
selector: Listify<TargetAccessSelector, 'target'>,
Expand Down
1 change: 0 additions & 1 deletion packages/services/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"devDependencies": {
"@envelop/core": "5.0.2",
"@envelop/generic-auth": "7.0.0",
"@envelop/graphql-jit": "8.0.3",
"@envelop/graphql-modules": "6.0.0",
"@envelop/opentelemetry": "6.3.1",
Expand Down
19 changes: 10 additions & 9 deletions packages/services/server/src/graphql-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ import {
type DefinitionNode,
type OperationDefinitionNode,
} from 'graphql';
import { createYoga, Plugin, useErrorHandler, useExecutionCancellation } from 'graphql-yoga';
import {
createYoga,
Plugin,
useErrorHandler,
useExecutionCancellation,
useExtendContext,
} from 'graphql-yoga';
import hyperid from 'hyperid';
import { isGraphQLError } from '@envelop/core';
import { useGenericAuth } from '@envelop/generic-auth';
import { useGraphQlJit } from '@envelop/graphql-jit';
import { useGraphQLModules } from '@envelop/graphql-modules';
import { useOpenTelemetry } from '@envelop/opentelemetry';
Expand Down Expand Up @@ -157,13 +162,9 @@ export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMeth
}
}
}),
useGenericAuth({
mode: 'resolve-only',
contextFieldName: 'session',
async resolveUserFn(ctx: Context) {
return options.authN.authenticate(ctx);
},
}),
useExtendContext(async context => ({
session: await options.authN.authenticate(context),
})),
useHive({
debug: true,
enabled: !!options.hiveConfig,
Expand Down
44 changes: 1 addition & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fbbdc3d

Please sign in to comment.