Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
  • Loading branch information
kduma committed Dec 19, 2023
1 parent ae3e378 commit 144fff0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
13 changes: 11 additions & 2 deletions content/1.systems/2.serverless-satis/1.s3-satis.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,22 @@ Or if it is not released version, but a branch, the file will be generated with
]
```

You can use this extension with CloudFlare Worker to provide a selective access to packages in your private repository.
You can use this extension with [CloudFlare Worker](/systems/serverless-satis/cloudflare-worker#selective-access)
to provide selective access to packages in your private repository.

If you enable `extra-json` option, generated tags will be added to `extra` section of Composer 2 `packages.json` file,
so you can filter them out in [CloudFlare Worker](/systems/serverless-satis/cloudflare-worker#selective-access)



```json
{
"s3-satis": {
"plugins": {
"file-restrictions-map-generator": true
"file-restrictions-map-generator": {
"enabled": true,
"extra-json": false
}
}
}
}
Expand Down
30 changes: 18 additions & 12 deletions content/1.systems/2.serverless-satis/3.cloudflare-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ npm run deploy

You need to update `wrangler.toml` file with your own values:

| Variable Name | Description |
|--------------------------------|-----------------------------------------------------------------------------------|
| `name` | Name of your CloudFlare Worker |
| `vars.PUBLIC_ACCESS_TO_INDEX` | If true, index page will be accessible without authentication |
| `vars.PUBLIC_ACCESS_TO_JSON` | If true, JSON indexes will be accessible without authentication |
| `vars.CHECK_FILE_RESTRICTIONS` | See [Selective Access](#selective-access) |
| `vars.STORE_PASSWORDS_HASHED` | See [Authentication](#authentication) |
| `vars.ENABLE_USER_ENDPOINT` | See [User Endpoint](#user-endpoint) |
| `routes.pattern` | Domain you want to expose your private repository on (need to use CloudFlare DNS) |
| `kv_namespaces.id` | Namespace ID of your Worker KV to read users from |
| `r2_buckets.bucket_name` | Name of private bucket where are stored files generated by `s3-satis` tool |
| Variable Name | Description |
|--------------------------------------|-----------------------------------------------------------------------------------|
| `name` | Name of your CloudFlare Worker |
| `vars.PUBLIC_ACCESS_TO_INDEX` | If true, index page will be accessible without authentication |
| `vars.PUBLIC_ACCESS_TO_JSON` | If true, JSON indexes will be accessible without authentication |
| `vars.CHECK_FILE_RESTRICTIONS` | See [Selective Access](#selective-access) |
| `vars.CHECK_EXTRA_JSON_RESTRICTIONS` | See [Selective Access](#selective-access) |
| `vars.STORE_PASSWORDS_HASHED` | See [Authentication](#authentication) |
| `vars.ENABLE_USER_ENDPOINT` | See [User Endpoint](#user-endpoint) |
| `routes.pattern` | Domain you want to expose your private repository on (need to use CloudFlare DNS) |
| `kv_namespaces.id` | Namespace ID of your Worker KV to read users from |
| `r2_buckets.bucket_name` | Name of private bucket where are stored files generated by `s3-satis` tool |

```toml
name = "<name>"
Expand All @@ -56,6 +57,7 @@ compatibility_date = "2023-12-06"
PUBLIC_ACCESS_TO_INDEX = false
PUBLIC_ACCESS_TO_JSON = false
CHECK_FILE_RESTRICTIONS = false
CHECK_EXTRA_JSON_RESTRICTIONS = false
STORE_PASSWORDS_HASHED = false
ENABLE_USER_ENDPOINT = false

Expand Down Expand Up @@ -104,4 +106,8 @@ password
vendor/package-1:1.x,vendor/package-2:2.0.0.0,vendor/package-3:dev-master
```

If user tries to access a package or version that is not listed in KV, the request will be rejected with `403 Forbidden` error.
If user tries to access a package or version that is not listed in KV, the request will be rejected with `403 Forbidden` error.

If you want to remove packages to which user doesn't have access from json files (so the composer won't complain about not having access to them when upgrading),
you cen enable [`extra-json` option in `file-restrictions-map-generator` extension of `s3-satis` tool](/systems/serverless-satis/s3-satis#file-restrictions-map-generator-extension-file-restrictions-map-generator),
and set `vars.CHECK_EXTRA_JSON_RESTRICTIONS` to `true`.

0 comments on commit 144fff0

Please sign in to comment.