Skip to content

Commit

Permalink
refactor: renamed whitelist as allowlist
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Jun 10, 2023
1 parent 53e8cec commit 4bd1975
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mods/connect/src/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const checkAccessFromPSTN = async (
return Auth.createForbideenResponse()
}

// Verify that the IP is whitelisted which means getting the access control list for the trunk
// Verify that the IP is allowlist which means getting the access control list for the trunk
if (trunk.accessControlList) {
try {
const allow = trunk.accessControlList.allow.filter((net: string) => {
Expand Down
1 change: 0 additions & 1 deletion mods/connect/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export const handleRegistry = (req: MessageRequest, res: Response) => {
)
}

// TODO: If request has X-Connect-Token then validate the JWT value and continue
export const handleRequest =
(location: ILocationService, apiClient?: CC.APIClient) =>
async (request: MessageRequest, res: Response) => {
Expand Down
2 changes: 1 addition & 1 deletion mods/simpleauth/src/envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import { Assertions as A } from "@routr/common"
A.assertEnvsAreSet(["PATH_TO_AUTH", "METHODS"])

export const BIND_ADDR = process.env.BIND_ADDR ?? "0.0.0.0:51903"
export const WHITELIST = process.env.WHITELIST?.split(",") ?? []
export const ALLOWLIST = process.env.ALLOWLIST?.split(",") ?? []
export const METHODS = process.env.METHODS?.split(",") ?? []
export const PATH_TO_AUTH = process.env.PATH_TO_AUTH
4 changes: 2 additions & 2 deletions mods/simpleauth/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require("./tracer").init("simpleauth")
import { User } from "./types"
import { getLogger } from "@fonoster/logger"
import { BIND_ADDR, METHODS, PATH_TO_AUTH, WHITELIST } from "./envs"
import { BIND_ADDR, METHODS, PATH_TO_AUTH, ALLOWLIST } from "./envs"
import simpleAuthProcessor from "./service"

const logger = getLogger({ service: "simpleauth", filePath: __filename })
Expand All @@ -32,7 +32,7 @@ try {
simpleAuthProcessor({
users,
bindAddr: BIND_ADDR,
whiteList: WHITELIST,
allowlist: ALLOWLIST,
methods: METHODS
})
} catch (e) {
Expand Down
10 changes: 5 additions & 5 deletions mods/simpleauth/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ const logger = getLogger({ service: "simpledata", filePath: __filename })

/**
* A simple authentication middleware that authenticates users based on a list of users
* or whitelisted endpoints paths.
* or allowlist endpoints paths.
*
* @param {MiddlewareConfig} config - configuration for the middleware
* @param {string} config.bindAddr - address to bind to
* @param {User[]} config.users - list of users
* @param {string[]} config.whiteList - list of path that required no authentication
* @param {string[]} config.allowlist - list of path that required no authentication
*/
export default function simpleAuthMiddleware(config: {
bindAddr: string
users: User[]
whiteList: string[]
allowlist: string[]
methods: string[]
}) {
const { bindAddr, users, whiteList, methods } = config
const { bindAddr, users, allowlist, methods } = config

new Processor({ bindAddr, name: "simpleauth" }).listen(
(req: MessageRequest, res: Response) => {
Expand All @@ -63,7 +63,7 @@ export default function simpleAuthMiddleware(config: {
return res.send(req)
}

if (whiteList.includes(req.message.from.address.uri.user)) {
if (allowlist.includes(req.message.from.address.uri.user)) {
span.addEvent(
`authenticated ${req.message.from.address.uri.user} from whitelist`
)
Expand Down

0 comments on commit 4bd1975

Please sign in to comment.