Skip to content

Commit 600e9ae

Browse files
authored
Merge pull request #1530 from hajkmap/feature/1529-FME-Server-proxy-add-token-auth
Added possibility to use Authorization token in FME Server proxy.
2 parents 9044435 + 910fe85 commit 600e9ae

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- LayerSwitcher(Client)/Groups(Admin): It's now possible to add and show information about a layer group. [#400](https://github.com/hajkmap/Hajk/issues/400).
3535
- LayerSwitcher: Some text field inputs for layer groups now allows HTML code. [#1518](https://github.com/hajkmap/Hajk/pull/1518).
3636
- CookieNotice: The cookie notice dialog now appears at the top of other dialogs and pop up windows. PR: [#1521](https://github.com/hajkmap/Hajk/pull/1521).
37+
- Backend (Node): Added possibility to use Authorization token in FME Server proxy. [#1530](https://github.com/hajkmap/Hajk/pull/1530).
3738

3839
### Fixed
3940

apps/backend/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ FB_SERVICE_PASS=
138138
#FME_SERVER_ACTIVE=true
139139
# The url to the FME-server instance.
140140
#FME_SERVER_BASE_URL=https://fmeserver.some.domain.com
141+
# Access to FME using authorization header. Either use USER+PASSWORD or TOKEN.
141142
# A FME-server user with access to some repository and workspace.
142143
#FME_SERVER_USER=someFmeUser
143144
# Password for the FME-server user supplied above.
144145
#FME_SERVER_PASSWORD=aGreatFmeUserPassWord
146+
# Access token for the FME-server.
147+
#FME_SERVER_TOKEN=00ce08a1c85e572612518e12e47a8b73151axxxx
145148
# If you are having problems with proxying to HTTPS FME Server, due
146149
# to self-signed certificates (SELF_SIGNED_CERT_IN_CHAIN), try setting this to "false"
147150
#FME_SERVER_SECURE=true

apps/backend/server/apis/v2/middlewares/fme.server.proxy.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ export default function fmeServerProxy(err, req, res, next) {
3030
secure: process.env.FME_SERVER_SECURE === "true", // should SSL certs be verified?
3131
onProxyReq: (proxyReq, req, res) => {
3232
// We have to add an authorization header to the request
33-
proxyReq.setHeader(
34-
"Authorization",
35-
`Basic ${Buffer.from(
36-
`${process.env.FME_SERVER_USER}:${process.env.FME_SERVER_PASSWORD}`
37-
).toString("base64")}`
38-
);
33+
// There are 2 possibilities: with TOKEN or with USER/PASS.
34+
const value = process.env.FME_SERVER_TOKEN
35+
? `fmetoken token=${process.env.FME_SERVER_TOKEN}`
36+
: `Basic ${Buffer.from(
37+
`${process.env.FME_SERVER_USER}:${process.env.FME_SERVER_PASSWORD}`
38+
).toString("base64")}`;
39+
proxyReq.setHeader("Authorization", value);
3940
},
4041
pathRewrite: (originalPath, req) => {
4142
// Lets split on the proxy path so that we can remove that when forwarding

0 commit comments

Comments
 (0)