Skip to content

feat: cloudflare access list#474

Merged
pajgo merged 1 commit intostagingfrom
feat/cloudflare-access-list
Oct 26, 2020
Merged

feat: cloudflare access list#474
pajgo merged 1 commit intostagingfrom
feat/cloudflare-access-list

Conversation

@pajgo
Copy link
Copy Markdown
Collaborator

@pajgo pajgo commented Sep 30, 2020

No description provided.

@pajgo pajgo force-pushed the feat/cloudflare-access-list branch 2 times, most recently from e69c6e6 to e2bc1ce Compare October 14, 2020 11:32
@pajgo pajgo marked this pull request as ready for review October 14, 2020 12:59
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 14, 2020

Codecov Report

Merging #474 into staging will increase coverage by 0.92%.
The diff coverage is 98.77%.

Impacted file tree graph

@@             Coverage Diff             @@
##           staging     #474      +/-   ##
===========================================
+ Coverage    87.38%   88.30%   +0.92%     
===========================================
  Files          149      157       +8     
  Lines         2759     3002     +243     
===========================================
+ Hits          2411     2651     +240     
- Misses         348      351       +3     
Impacted Files Coverage Δ
src/utils/cloudflare/worker.js 91.66% <91.66%> (ø)
src/actions/cf/add-to-access-list.js 100.00% <100.00%> (ø)
src/actions/login.js 90.69% <100.00%> (+0.22%) ⬆️
src/configs/cloudflare-list.js 100.00% <100.00%> (ø)
src/configs/consul.js 100.00% <100.00%> (ø)
src/custom/cappasity-cf-access-list.js 100.00% <100.00%> (ø)
src/users.js 93.42% <100.00%> (+1.11%) ⬆️
src/utils/cloudflare/api.js 100.00% <100.00%> (ø)
src/utils/cloudflare/client.js 100.00% <100.00%> (ø)
src/utils/cloudflare/ip-list.js 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 090cbb6...175153f. Read the comment docs.

Comment thread src/configs/core.js Outdated
'redisCluster',
'http',
'prometheus',
'consul',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change, instead of updating default list of plugins, setup this as a dependency on the cf-worker and its action. if worker or action is enabled during startup, push consul plugin into init configuration

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added check whether consul plugin included in configuration, for now.
Think we should add a feature that allows us to include plugins in the constructor of the @microfleet/core plugin system?

Comment thread src/custom/cappasity-cf-access-list.js Outdated
const route = `${routes.prefix ? `${routes.prefix}.` : ''}cf.add-to-access-list`;

if (remoteip !== false && user.metadata[audience].plan !== 'free') {
await amqp.publish(route, { remoteip });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may want to add confirm, mandatory and deliveryMode flags for amqp, otherwise this may not be published

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread src/utils/cloudflare/api.js Outdated

class CloudflareAPI {
constructor(cfClient, config = {}, withProps = {}) {
assert(cfClient instanceof CloudflareClient, 'invalid client');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont allow stubbing during tests, so I'd add a condition that this is not a test environment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed instanceof check, the constructor now checks the existence of parameter.

Comment thread src/utils/cloudflare/api.js Outdated
Comment on lines +33 to +38
apiUrl(t, values) {
const { accountId } = this.props;
assert(accountId, 'accountId invalid');
return Object.entries({ accountId, ...values })
.reduce((prev, [prop, val]) => prev.replace(`:${prop}`, val), t);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an expensive operation (iterating, searching, replacing) - consider using template literals (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to template literals + extra Fns.

Comment thread src/utils/cloudflare/api.js Outdated
Comment on lines +65 to +76
return retry(
async (retryFn) => {
try {
const response = await this.http.get(url);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this implementation doesnt look good, try this module with retry by default and explicit error that needs to be thrown (pRetry.abort) to abort retries https://www.npmjs.com/package/p-retry

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed package + added extra tests

@pajgo pajgo force-pushed the feat/cloudflare-access-list branch from 326f5ce to 711801d Compare October 22, 2020 09:47
feat(cf-access-list): Cloudflare Ip List sync worker

test(cf-access-list): fix test to ip binding
@pajgo pajgo force-pushed the feat/cloudflare-access-list branch from b203bd2 to 175153f Compare October 26, 2020 08:08
@pajgo pajgo merged commit 0f6062d into staging Oct 26, 2020
@pajgo pajgo deleted the feat/cloudflare-access-list branch October 26, 2020 08:27
AVVS pushed a commit that referenced this pull request Oct 26, 2020
# [14.12.0-rc.1](v14.11.1-rc.1...v14.12.0-rc.1) (2020-10-26)

### Features

* **cf-access-list:** Cloudflare Ip List API + client ([#474](#474)) ([0f6062d](0f6062d))
* edit tbits authenticate ([#479](#479)) ([090cbb6](090cbb6))
@AVVS
Copy link
Copy Markdown
Member

AVVS commented Oct 26, 2020

🎉 This PR is included in version 14.12.0-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@pajgo pajgo restored the feat/cloudflare-access-list branch October 27, 2020 06:54
pajgo added a commit that referenced this pull request Nov 3, 2020
feat(cf-access-list): Cloudflare Ip List sync worker
test(cf-access-list): Fix test to ip binding
pajgo added a commit that referenced this pull request Nov 3, 2020
* fix: added rc release
* fix: added clear cache on create, update organization (#475)
* fix: added clear cache on create, update organization
* fix: added debug for send invite mail
* fix: added remove user from org on user.remove, edit generate email (#476)
* fix: added username to query on organization invite mail
* fix: added username to query on organization register mail
* feat: edit tbits authenticate (#479)
* feat(cf-access-list): Cloudflare Ip List API + client (#474)
* feat(cf-access-list): Cloudflare Ip List sync worker

Co-authored-by: Pavel Rogovoi <51755949+pajgo@users.noreply.github.com>
AVVS pushed a commit that referenced this pull request Nov 3, 2020
## [14.12.1](v14.12.0...v14.12.1) (2020-11-03)

### Bug Fixes

* organization members ([#477](#477)) ([4628b3e](4628b3e)), closes [#475](#475) [#476](#476) [#479](#479) [#474](#474)
@pajgo pajgo deleted the feat/cloudflare-access-list branch November 23, 2020 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants