Skip to content

Commit 99353c6

Browse files
committed
Make Chirpstack JWT secret configurable
1 parent c48896d commit 99353c6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/config/configuration.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ export default (): any => {
2424
process.env.KOMBIT_ROLE_NAME ||
2525
"http://os2iot.dk/roles/usersystemrole/adgang/",
2626
},
27+
chirpstack: {
28+
jwtsecret: process.env.CHIRPSTACK_JWTSECRET || "verysecret",
29+
},
2730
};
2831
};

src/services/chirpstack/jwt-token.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Injectable, Logger } from "@nestjs/common";
1+
import configuration from "@config/configuration";
2+
import { Injectable } from "@nestjs/common";
23
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
// @ts-ignore
45
import * as nJwt from "njwt";
@@ -16,9 +17,12 @@ export class JwtToken {
1617
username: "admin", // username the client claims to be
1718
};
1819

19-
const jwt = nJwt.create(claims, "verysecret", "HS256");
20+
const jwt = nJwt.create(
21+
claims,
22+
configuration()["chirpstack"]["jwtsecret"],
23+
"HS256"
24+
);
2025
const token = jwt.compact();
21-
// Logger.verbose(`JWT token for Chirpstack: ${token}`);
2226
return token;
2327
}
2428
}

0 commit comments

Comments
 (0)