-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code review points. Add `Dockerfile` See <#399> for further information.
- Loading branch information
Mohamed Bana
committed
Jun 8, 2022
1 parent
c4145f8
commit 6489695
Showing
9 changed files
with
140 additions
and
13 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ples/ext_authz/ext-authz-staticroute.yaml → ...ples/ext-authz/ext-authz-staticroute.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM docker.io/library/node:16.14.0-alpine3.15 | ||
|
||
COPY . /app | ||
WORKDIR /app/http-service | ||
RUN npm install | ||
|
||
EXPOSE 9002 | ||
|
||
CMD ["node", "/app/http-service/server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `HTTP-SERVICE` | ||
|
||
Taken from <https://github.com/envoyproxy/envoy/tree/main/examples/ext_authz> in particular <https://github.com/envoyproxy/envoy/blob/main/examples/ext_authz/auth/http-service/server.js>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const express = require('express') | ||
const auth = require('basic-auth') | ||
const app = express() | ||
const port = process.env.PORT || 9002; | ||
|
||
app.use((req, res, next) => { | ||
console.log("headers=", req.headers) | ||
console.log("auth(req)=", auth(req)) | ||
|
||
const { name: user, pass } = auth(req) | ||
console.log("user=", user) | ||
console.log("pass=", pass) | ||
|
||
if (user === 'kubeshop' && pass === 'kubeshop') { | ||
// res.status(200) | ||
// res.writeHead(200); | ||
res.writeHead(200, { "x-current-user": user }); | ||
|
||
res.end() | ||
} else { | ||
res.status(401) | ||
// res.status(403) | ||
|
||
res.end('Unauthorized - hint: credentials are kubeshop:kubeshop') | ||
} | ||
}) | ||
|
||
app.listen(port, () => console.log(`ext-authz-http-service: server.js listening on port ${port}!`)) | ||
|
||
//// Taken from https://github.com/envoyproxy/envoy/blob/main/examples/ext_authz/auth/http-service/server.js | ||
// const Http = require("http"); | ||
// const path = require("path"); | ||
|
||
// const tokens = require(process.env.USERS || | ||
// path.join(__dirname, "..", "users.json")); | ||
|
||
// const server = new Http.Server((req, res) => { | ||
// const authorization = req.headers["authorization"] || ""; | ||
// const extracted = authorization.split(" "); | ||
// if (extracted.length === 2 && extracted[0] === "Bearer") { | ||
// const user = checkToken(extracted[1]); | ||
// if (user !== undefined) { | ||
// // The authorization server returns a response with "x-current-user" header for a successful | ||
// // request. | ||
// res.writeHead(200, { "x-current-user": user }); | ||
// return res.end(); | ||
// } | ||
// } | ||
// res.writeHead(403); | ||
// res.end(); | ||
// }); | ||
|
||
// const port = process.env.PORT || 9002; | ||
// server.listen(port); | ||
// console.log(`starting HTTP server on: ${port}`); | ||
|
||
// function checkToken(token) { | ||
// return tokens[token]; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env sh | ||
set -euf | ||
|
||
docker build --no-cache \ | ||
-t kubeshop/kusk-ext-authz-http-service:v0.0.1 \ | ||
-t kubeshop/kusk-ext-authz-http-service:latest \ | ||
-t kusk-ext-authz-http-service:latest \ | ||
-t kusk-ext-authz-http-service:v0.0.1 \ | ||
--file ./http-service/Dockerfile . | ||
|
||
docker push kubeshop/kusk-ext-authz-http-service:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters