Skip to content
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

New user management multiple levels #174

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3004f63
Add flow for hiding new welcome screen (#172)
AramAlsabti May 16, 2022
08a0d9f
Merge permission entities into one. Support multiple levels per permi…
AramAlsabti May 16, 2022
465b696
Fix some test errors
AramAlsabti May 16, 2022
b0ee442
Feature/iot 1320 fix sig fox connection (#165)
GufCab May 17, 2022
e5eb648
Feature/iot 1249 manage kombit users merged (#168)
augusthjerrild May 17, 2022
7b549fb
Bumped momemnt version one minor version
May 17, 2022
0c93753
Fixed package.lock
May 17, 2022
8bf6b21
Fixed casing of Kombit migration
May 17, 2022
74d4563
Finish permission levels migration
AramAlsabti May 17, 2022
2436f95
Deny duplicate permission types
AramAlsabti May 17, 2022
6c80274
Constrain permission type to enum
AramAlsabti May 18, 2022
11c6f08
Removed unused permission types
AramAlsabti May 18, 2022
5a028fe
Merge branch 'stage' into feature/1242_new-user-management-multiple-l…
AramAlsabti May 18, 2022
ea07580
Fix kombit permissions
AramAlsabti May 18, 2022
2da087c
Show overview of gateway status (#170)
AramAlsabti May 18, 2022
b0fc6e7
Update accept kombit to use group instead of level
AramAlsabti May 18, 2022
4e867df
Merge remote-tracking branch 'origin/stage' into feature/1242_new-use…
AramAlsabti May 18, 2022
caabf3c
Remove permission check from gateway status
AramAlsabti May 18, 2022
ccf13f3
Cleanup permission relations on down
AramAlsabti May 19, 2022
a0edef9
Fix multiple permission relations not mapped to the same new permissions
AramAlsabti May 19, 2022
691d96f
Fix global admin not created on startup
AramAlsabti May 19, 2022
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
104 changes: 101 additions & 3 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@
"mqtt": "^4.2.6",
"nestjs-pino": "^1.3.0",
"njwt": "^1.0.0",
"nodemailer": "^6.7.2",
"passport": "^0.4.1",
"passport-headerapikey": "^1.2.2",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"passport-saml": "^1.3.5",
"pg": "^8.5.1",
"protobufjs": "^6.11.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
Expand All @@ -83,6 +85,7 @@
"@types/express": "^4.17.9",
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.14",
"@types/nodemailer": "^6.4.4",
"@types/passport-jwt": "^3.0.3",
"@types/passport-local": "^1.0.33",
"@types/supertest": "^2.0.10",
Expand Down
16 changes: 16 additions & 0 deletions resources/chirpstack-state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

package gw;

// ConnState contains the connection state of a gateway.
message ConnState {
// Gateway ID.
bytes gateway_id = 1 [json_name = "gatewayID"];

enum State {
OFFLINE = 0;
ONLINE = 1;
}

State state = 2;
}
13 changes: 12 additions & 1 deletion src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,16 @@ export default (): any => {
logLevels: process.env.LOG_LEVEL
? GetLogLevels(process.env.LOG_LEVEL)
: GetLogLevels("debug"),
};
email: {
host: process.env.EMAIL_HOST || "smtp.ethereal.email",
port: process.env.EMAIL_PORT || 587,
user: process.env.EMAIL_USER || "[email protected]",
pass: process.env.EMAIL_PASS || "KzRSyYReEygpFPPZdd",
from: process.env.EMAIL_FROM || "[email protected]"
},
frontend: {
baseurl:
process.env.FRONTEND_BASEURL || "http://localhost:8081"
}
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ComposeAuthGuard } from "@auth/compose-auth.guard";
import { Read } from "@auth/roles.decorator";
import { RolesGuard } from "@auth/roles.guard";
import {
GatewayGetAllStatusResponseDto,
ListAllGatewayStatusDto,
} from "@dto/chirpstack/backend/gateway-all-status.dto";
import { GatewayStatus, GetGatewayStatusQuery } from "@dto/chirpstack/backend/gateway-status.dto";
import { AuthenticatedRequest } from "@dto/internal/authenticated-request";
import { Controller, Get, Param, Query, Req, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiOperation, ApiProduces, ApiTags } from "@nestjs/swagger";
import { ChirpstackGatewayService } from "@services/chirpstack/chirpstack-gateway.service";
import { GatewayStatusHistoryService } from "@services/chirpstack/gateway-status-history.service";
import { checkIfUserHasAccessToOrganization, OrganizationAccessScope } from "@helpers/security-helper";

@ApiTags("LoRaWAN gateway")
@Controller("lorawan/gateway")
@UseGuards(ComposeAuthGuard, RolesGuard)
@ApiBearerAuth()
export class LoRaWANGatewayController {
constructor(
private onlineHistoryService: GatewayStatusHistoryService,
private chirpstackGatewayService: ChirpstackGatewayService
) {}

@Get("/status")
@ApiProduces("application/json")
@ApiOperation({ summary: "Get the status for all LoRaWAN gateways" })
@Read()
async getAllStatus(
@Req() req: AuthenticatedRequest,
@Query() query: ListAllGatewayStatusDto
): Promise<GatewayGetAllStatusResponseDto> {
// Currently, everyone is allowed to get the status
return this.onlineHistoryService.findAllWithChirpstack(query);
}

@Get("/status/:id")
@ApiProduces("application/json")
@ApiOperation({ summary: "Get the status for a LoRaWAN gateway" })
async getStatus(
@Req() req: AuthenticatedRequest,
@Param("id") id: string,
@Query() query: GetGatewayStatusQuery
): Promise<GatewayStatus> {
// Currently, everyone is allowed to get the status
const gatewayDto = await this.chirpstackGatewayService.getOne(id);
return this.onlineHistoryService.findOne(gatewayDto.gateway, query.timeInterval);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class SigfoxGroupController {

@Get(":id")
@ApiProduces("application/json")
@ApiOperation({ summary: "List a SigFox Groups" })
@ApiOperation({ summary: "Get one group by ID" })
@Read()
async getOne(
@Req() req: AuthenticatedRequest,
Expand All @@ -78,7 +78,7 @@ export class SigfoxGroupController {
try {
group = await this.service.findOne(id);
} catch (err) {
throw new NotFoundException();
return null;
}
checkIfUserHasAccessToOrganization(req, group.belongsTo.id, OrganizationAccessScope.ApplicationRead);
return group;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ReceiveDataController {
// @HACK: Convert the 'data' back to a string.
// NestJS / BodyParser always converts the input to an object for us.
const dataAsString = JSON.stringify(data);
await this.receiveDataService.sendToKafka(
await this.receiveDataService.sendRawIotDeviceRequestToKafka(
iotDevice,
dataAsString,
IoTDeviceType.GenericHttp.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SigFoxListenerController {
const sigfoxDevice = await this.findSigFoxDevice(data);

const dataAsString = JSON.stringify(data);
await this.receiveDataService.sendToKafka(
await this.receiveDataService.sendRawIotDeviceRequestToKafka(
sigfoxDevice,
dataAsString,
IoTDeviceType.SigFox.toString(),
Expand Down
1 change: 0 additions & 1 deletion src/controllers/user-management/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
import { JwtPayloadDto } from "@dto/internal/jwt-payload.dto";
import { LoginDto } from "@dto/login.dto";
import { Organization } from "@entities/organization.entity";
import { OrganizationPermission } from "@entities/permissions/organization-permission.entity";
import { User } from "@entities/user.entity";
import { PermissionType } from "@enum/permission-type.enum";
import { AuthService } from "@services/user-management/auth.service";
Expand Down
Loading