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

Version 4: Resolution of security (pen test) findings, dependancy vulnerabilities and other small updates #45

Merged
merged 22 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8455c15
fix: uri encode template replacement to ovoid XSS
SiCoe Sep 22, 2023
d9e32aa
NONCE and CV cookies as `secure` for pkce
SiCoe Sep 22, 2023
6fc36a2
all cookies sameSite as Strict for pkce
SiCoe Sep 25, 2023
c5fc6c4
HTML instead of URI encoding for unauthorized body
SiCoe Sep 25, 2023
801f50d
include nodejs18.x in build targets
SiCoe Sep 25, 2023
7d0c091
reference version 4 in docs and examples
SiCoe Sep 25, 2023
35b12be
Merge pull request #41 from iress/node-18
SiCoe Sep 26, 2023
bf49023
Merge pull request #39 from iress/DP-481
SiCoe Sep 26, 2023
d1a2225
Merge branch 'v4' into DP-479
SiCoe Sep 26, 2023
fee9836
Merge pull request #40 from iress/DP-479
SiCoe Sep 26, 2023
ac267da
use sameSite: strict and secure for openid
SiCoe Sep 26, 2023
360ada9
use sameSite: strict and secure for github
SiCoe Sep 26, 2023
c84be23
Merge pull request #42 from iress/openid-secure-samesite
SiCoe Sep 26, 2023
888a212
include node 14 in "engines" of package
SiCoe Sep 26, 2023
abc09fa
correct footers to correct repository url
SiCoe Sep 27, 2023
d34734d
include Content-Type header in responses
SiCoe Sep 27, 2023
60915a5
Merge pull request #44 from iress/content-type
SiCoe Sep 27, 2023
d46dbbe
Merge branch 'v4' into footer
SiCoe Sep 27, 2023
0d6d923
Merge pull request #43 from iress/footer
SiCoe Sep 27, 2023
185bfdb
replace dependancy 'entities' with 'html-entities'
SiCoe Oct 2, 2023
1d9f87a
Merge pull request #38 from iress/DP-803
SiCoe Oct 2, 2023
4454871
update npm dependancies to remove vulnerabilities
SiCoe Oct 2, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Detailed instructions on testing your function can be found [in the Wiki](https:
## Build Requirements

* [npm](https://www.npmjs.com/) ^7.20.0
* [node](https://nodejs.org/en/) ^14.0
* [node](https://nodejs.org/en/) ^18.0
* [openssl](https://www.openssl.org)

## Building Generic Packages
Expand All @@ -179,7 +179,9 @@ The supported values of `package` are:
* `okta_native` - builds a generic Lambda package for OKTA Native authentication
* `rotate_key_pair` - builds a Lambda package for rotating the RSA keys in AWS Secrets Manager

GitHub Actions automatically creates a new GitHub release when the repository owner pushes a tag that begins with `v`:
GitHub Actions automatically creates a new GitHub release when the repository owner pushes a tag that begins with `v`.

e.g.

```sh
git tag -a -m "Target AWS Lambda Node.js 14.x runtime" v3.0.0
Expand Down
51 changes: 38 additions & 13 deletions authn/github.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,33 @@ function mainProcess(event, context, callback) {
"statusDescription": "Found",
"body": "ID token retrieved.",
"headers": {
"content-type": [{
"key": "Content-Type",
"value": "text/plain;charset=UTF-8"
}],
"location" : [{
"key": "Location",
"value": event.Records[0].cf.config.hasOwnProperty('test') ? (config.AUTH_REQUEST.redirect_uri + queryDict.state) : queryDict.state
}],
"set-cookie" : [{
"key": "Set-Cookie",
"value" : cookie.serialize('TOKEN', jwt.sign(
{ },
config.PRIVATE_KEY.trim(),
"value" : cookie.serialize(
'TOKEN',
jwt.sign(
{ },
config.PRIVATE_KEY.trim(),
{
audience: headers.host[0].value,
subject: auth.getSubject(username),
expiresIn: config.SESSION_DURATION,
algorithm: 'RS256'
} // Options
),
{
audience: headers.host[0].value,
subject: auth.getSubject(username),
expiresIn: config.SESSION_DURATION,
algorithm: 'RS256'
} // Options
))
sameSite: 'strict',
secure: true
}
)
}],
},
};
Expand Down Expand Up @@ -140,6 +151,10 @@ function redirect(request, headers, callback) {
statusDescription: "Found",
body: "Redirecting to OAuth2 provider",
headers: {
"content-type": [{
"key": "Content-Type",
"value": "text/plain;charset=UTF-8"
}],
"location" : [{
"key": "Location",
"value": config.AUTHORIZATION_ENDPOINT + '?' + querystring
Expand All @@ -159,10 +174,14 @@ function unauthorized(body, callback) {
"statusDescription": "Unauthorized",
"body": body,
"headers": {
"set-cookie" : [{
"key": "Set-Cookie",
"value" : cookie.serialize('TOKEN', '', { path: '/', expires: new Date(1970, 1, 1, 0, 0, 0, 0) })
}],
"content-type": [{
"key": "Content-Type",
"value": "text/plain;charset=UTF-8"
}],
"set-cookie" : [{
"key": "Set-Cookie",
"value" : cookie.serialize('TOKEN', '', { path: '/', expires: new Date(1970, 1, 1, 0, 0, 0, 0) })
}],
},
};
callback(null, response);
Expand All @@ -173,6 +192,12 @@ function internalServerError(body, callback) {
"status": "500",
"statusDescription": "Internal Server Error",
"body": body,
"headers": {
"content-type": [{
"key": "Content-Type",
"value": "text/plain;charset=UTF-8"
}]
}
};
callback(null, response);
}
94 changes: 59 additions & 35 deletions authn/openid.index.js

Large diffs are not rendered by default.

91 changes: 56 additions & 35 deletions authn/pkce.index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion infra/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Terraform modules for each identity provider are in the [modules](./modules)
source = "github.com/iress/cloudfront-auth//infra/terraform/modules/okta_native"
# Lambda function version to deploy (see the Releases page of this GitHub repository)
release_version = "v3.0.0"
release_version = "v4.0.0"
name = "my-website-auth"
org_url = "https://my-org.okta.com/oauth2/default"
Expand Down
2 changes: 1 addition & 1 deletion infra/terraform/examples/okta-native/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
module "auth" {
source = "github.com/iress/cloudfront-auth//infra/terraform/modules/okta_native"

release_version = "v3.0.0"
release_version = "v4.0.0"
name = local.name
org_url = "https://my-org.okta.com/oauth2/default"
client_id = "Nf2qSD9wXKU9ph8an22T"
Expand Down
2 changes: 1 addition & 1 deletion infra/terraform/modules/_lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resource "aws_lambda_function" "main" {
role = aws_iam_role.lambda.arn
handler = "index.handler"
source_code_hash = base64sha256(var.package_url)
runtime = "nodejs14.x"
runtime = "nodejs18.x"
timeout = var.timeout
publish = var.lambda_at_edge
tags = var.tags
Expand Down
Loading
Loading