GithubHelp home page GithubHelp logo

juju / bakeryjs Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 9.0 588 KB

Javascript implementation of the Macaroon Bakery

License: GNU Lesser General Public License v3.0

JavaScript 3.02% TypeScript 96.98%

bakeryjs's Introduction

Juju logo next to the text Canonical Juju

Juju is an open source application orchestration engine that enables any application operation (deployment, integration, lifecycle management) on any infrastructure (Kubernetes or otherwise) at any scale (development or production) in the same easy way (typically, one line of code), through special operators called β€˜charms’.

juju snap build

πŸ‘‰ Juju Learn how to quickly deploy, integrate, and manage charms on any cloud with Juju.
It's as simple as juju deploy foo, juju integrate foo bar, ..., on any cloud.
Charmhub Sample our existing charms on Charmhub.
A charm can be a cluster (OpenStack, Kubernetes), a data platform (PostgreSQL, MongoDB, etc.), an observability stack (Canonical Observability Stack), an MLOps solution (Kubeflow), and so much more.
Charm SDK Write your own charm!
Juju is written in Go, but our SDK supports easy charm development in Python.

Give it a try!

Let's use Juju to deploy, configure, and integrate some Kubernetes charms:

Set up

You will need a cloud and Juju. The quickest way is to use a Multipass VM launched with the charm-dev blueprint.

Install Multipass: Linux | macOS | Windows. On Linux:

sudo snap install multipass

Use Multipass to launch an Ubuntu VM with the charm-dev blueprint:

multipass launch --cpus 4 --memory 8G --disk 30G --name tutorial-vm charm-dev 

Open a shell into the VM:

multipass shell tutorial-vm

Verify that you have Juju and two localhost clouds:

juju clouds

Bootstrap a Juju controller into the MicroK8s cloud:

juju bootstrap microk8s tutorial-controller

Add a workspace, or 'model':

juju add-model tutorial-model

Deploy, configure, and integrate a few things

Deploy Mattermost:

juju deploy mattermost-k8s

See more: Charmhub | mattermost-k8s

Deploy PostgreSQL:

juju deploy postgresql-k8s --channel 14/stable --trust

See more: Charmhub | postgresql-k8s

Enable security in your PostgreSQL deployment:

juju deploy tls-certificates-operator
juju config tls-certificates-operator generate-self-signed-certificates="true" ca-common-name="Test CA"
juju integrate postgresql-k8s tls-certificates-operator

Integrate Mattermost with PostgreSQL:

juju integrate mattermost-k8s postgresql-k8s:db

Watch your deployment come to life:

juju status --watch 1s

(Press Ctrl-C to quit. Drop the --watch 1s flag to get the status statically. Use the --relations flag to view more information about your integrations.)

Test your deployment

When everything is in active or idle status, note the IP address and port of Mattermost and pass them to curl:

curl <IP address>:<port>/api/v4/system/ping

You should see the output below:

{"AndroidLatestVersion":"","AndroidMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}

Congratulations!

You now have a Kubernetes deployment consisting of a Mattermost backed by PosgreSQL with TLS-encrypted traffic!

Clean up

Delete your Multipass VM:

multipass delete --purge tutorial-vm

Uninstall Multipass: Linux | macOS | Windows. On Linux:

snap remove multipass

Next steps

Learn more

Chat with us

Read our Code of conduct and:

File an issue

Make your mark

bakeryjs's People

Contributors

anthonydillon avatar dependabot[bot] avatar frankban avatar goulinkh avatar hatched avatar huwshimi avatar petermakowski avatar squidsoup avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bakeryjs's Issues

Add documentation

This documentation could include:

  • What does this package do?
  • Who should use this lib?
  • How do I interface with this library?
  • Why is it named "bakery"?
  • What is a "macaroon"?
  • API/Functions etc. descriptions.
  • Usage examples.
  • List of projects that use it.

visit func can be called multiple times

If a macaroon key changes on the server, the next request(s) can result in multiple calls to visit which opens n windows per request. While this isn't likely to occur in production frequently, it can result in some surprising behaviour to the user, particularly if the client is making quite a few requests.

Would it be possible to make calls to the visit function more state aware, so that only one tab/window will be opened at once?

callback not being called in case of TLS cert error in bakery request

When bakery tries to discharge a 3rd party caveat to an https endpoint whose certificate is not trusted (e.g. self-signed), the POST /discharge fails, but the error is not propagated to the caller's callback as it doesn't contain a JSON text in the body (IOW, JSON.parse() fails).

As a side note, it would be nice if the returned error could always be a string, so that the caller can use it for user feedback.

Webpack > 5 no longer polyfills node.js core modules

Webpack > 5 no longer polyfills node.js core modules by default, so getting bakeryjs working requires installing a few core modules as well. These packages should probably be included explicitly as part of this project.

These core modules include buffer, crypto, stream and util.

Unique macaroon stored for every url

Currently, every request made by the bakery stores a unique macaroon for that url, resulting in a macaroon handshake for every new request. The internal implementation appears to store macaroons by url rather than host.

Migrate to yarn

As we're using yarn for other projects, consider migrating this project to yarn.

Migrate to typescript

It would be very helpful if this was migrated to TypeScript to provide type definitions for the consuming projects.

Compiled typescript is failing

When building a project like jujulib we are getting the following output:

$ yarn build
yarn run v1.22.19
$ tsc
node_modules/@canonical/macaroon-bakery/dist/bakery.d.ts:12:66 - error TS7016: Could not find a declaration file for module 'macaroon'. '/home/goulin/Lab/juju/js-libjuju/node_modules/macaroon/macaroon.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/macaroon` if it exists or add a new declaration (.d.ts) file containing `declare module 'macaroon';`

12 import { Macaroon, Error as MacaroonError, MacaroonObject } from "macaroon";
                                                                    ~~~~~~~~~~


Found 1 error in node_modules/@canonical/macaroon-bakery/dist/bakery.d.ts:12

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Return response headers

Ideally the xhr object from _request could be returned with response headers (needed for pagination etc.).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.