Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 174 additions & 4 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^9.0.0",
"@types/passport-jwt": "^3.0.13",
"casbin": "^5.28.0",
"casbin-mongoose-adapter": "^5.3.1",
"csv-parser": "^3.0.0",
"graphql-type-json": "^0.3.2",
"jsonschema": "^1.4.1",
Expand Down
9 changes: 1 addition & 8 deletions packages/server/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ type Mutation {
createDataset(dataset: DatasetCreate!): Dataset!
changeDatasetName(dataset: ID!, newName: String!): Boolean!
changeDatasetDescription(dataset: ID!, newDescription: String!): Boolean!
grantOwner(targetUser: ID!): Boolean!
signLabCreateProject(project: ProjectCreate!): Project!
deleteProject(project: ID!): Boolean!
createStudy(study: StudyCreate!): Study!
deleteStudy(study: ID!): Boolean!
changeStudyName(study: ID!, newName: String!): Study!
changeStudyDescription(study: ID!, newDescription: String!): Study!
createEntry(entry: EntryCreate!, dataset: ID!): Entry!
createUploadSession(dataset: ID!): UploadSession!
completeUploadSession(session: ID!): UploadResult!
createTags(study: ID!, entries: [ID!]!): [Tag!]!
Expand Down Expand Up @@ -162,11 +162,4 @@ input StudyCreate {
input TagSchemaInput {
dataSchema: JSON!
uiSchema: JSON!
}

input EntryCreate {
entryID: String!
contentType: String!
creator: ID!
meta: JSON!
}
8 changes: 6 additions & 2 deletions packages/server/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { JwtStrategy } from './jwt.strategy';
import { JwtAuthGuard } from './jwt.guard';
import { OrganizationModule } from '../organization/organization.module';
import { HttpModule } from '@nestjs/axios';
import { casbinProvider } from './casbin.provider';
import { AuthResolver } from './auth.resolver';

@Module({
imports: [
Expand All @@ -24,11 +26,13 @@ import { HttpModule } from '@nestjs/axios';
};
return options;
}
})
}),
],
providers: [
AuthService,
JwtAuthGuard,
casbinProvider,
AuthResolver,
{
provide: JwtStrategy,
inject: [AuthService],
Expand All @@ -38,6 +42,6 @@ import { HttpModule } from '@nestjs/axios';
}
}
],
exports: [AuthService]
exports: [AuthService, casbinProvider]
})
export class AuthModule {}
22 changes: 22 additions & 0 deletions packages/server/src/auth/auth.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Resolver, Mutation, Args, ID } from '@nestjs/graphql';
import { JwtAuthGuard } from './jwt.guard';
import { UseGuards } from '@nestjs/common';
import { UserContext } from './user.decorator';
import { TokenPayload } from './user.dto';
import { AuthService } from './auth.service';
import {OrganizationContext} from 'src/organization/organization.context';
import {Organization} from 'src/organization/organization.model';

@UseGuards(JwtAuthGuard)
@Resolver()
export class AuthResolver {
constructor(private readonly authService: AuthService) {}

@Mutation(() => Boolean)
async grantOwner(@Args('targetUser', { type: () => ID }) targetUser: string,
@UserContext() requestingUser: TokenPayload,
@OrganizationContext() organization: Organization): Promise<boolean> {
await this.authService.grantOwner(targetUser, requestingUser.id, organization._id);
return true;
}
}
Loading