core

command module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

Go Report Card Build status Go Reference Quality Gate Status

openlane

This repository houses the core server and orchestration elements which are at the heart of the openlane cloud service.

Features

At it's core, this repo is a collection of services built on top of an entity framework which allows us to:

  • Model database schemas as graph structures
  • Define schemas as programmatic go code
  • Execute complex database queries and graph traversals easily
  • Extend and customize using templates and code generation utilities
  • Type-safe resolvers and GraphQL schema stitching
  • Code generated audit / history tables for defined schemas

On top of this powerful core we also have an incredible amount of pluggable, extensible services:

  • Authentication: we today support password, OAuth2 / Social login providers (Github, Google), Passkeys as well as standard OIDC Discovery flows
  • Multi-factor: built-in 2FA mechanisms, TOTP
  • Authorization: extensible and flexible permissions constructs via openFGA based on Google Zanzibar
  • Session Management: built-in session management with JWKS key validation, encrypted cookies and sessions
  • Robust Middleware: cache control, CORS, Rate Limiting, transaction rollbacks, and more
  • Queuing and Scheduling: Task management and scheduling with riverqueue
  • External Storage Providers: store data in AWS S3, Google GCS, or locally
  • External Database Providers: Leverage NeonDB, or other PostgreSQL compatible vendors and libraries
  • Data Isolation and Management: Hierarchal organizations and granular permissions controls

Development

Dependencies

The vast majority of behaviors of the system can be turned on or off by updating the configuration parameters found in config; in some instances, we've made features or integrations with third party systems which are "always on", but we're happy to receive PR's wrapping those dependencies if you are interested in running the software without them!

Installing Dependencies

Setup Taskfile by following the instructions and using one of the various convenient package managers or installation scripts. After installation, you can then simply run task install to load the associated dependencies. Nearly everything in this repository assumes you already have a local golang environment setup so this is not included. Please see the associated documentation.

Updating Configuration Settings

See the README in the config directory.

Starting the Server
  1. Copy the config, this is in .gitignore so you do not have to worry about accidentally committing secrets

    cp ./config/config-dev.example.yaml ./config/.config.yaml
    
  2. Update the configuration with whatever respective settings you desire; the defaults inside should allow you to run the server without a problem

  3. Use the task commands to start the server

    Run the core server in development mode with dependencies in docker

    task run-dev
    

    Run fully in docker

    task docker:all:up
    
  4. In a separate terminal, with the server running, you can create a verified test user by running:

    task cli:user:all
    
  5. Once this command has finished ^, you can login and perform actions as user mitb@theopenlane.io with password mattisthebest1234

Creating Queries in GraphQL

The best method of forming / testing queries against the server is to run task docker:rover which will launch an interactive query UI.

If you are running the queries against your local repo, you will have CORS issues using the local running apollo. Instead, its recommended to use the apollo sandbox and ensure the following origin is allowed in your config/.config.yaml

server:
  cors:
    allowOrigins:
      - https://studio.apollographql.com
OpenFGA Playground

You can load up a local openFGA environment with the compose setup in this repository; task fga:up - this will launch an interactive playground where you can model permissions model(s) or changes to the models

Creating a new Schema

To ease the effort required to add additional schemas into the system a template + task function has been created. This isn't doing anything terribly complex, but it's attempting to ensure you have the minimum set of required things needed to create a schema - most notably: you need to ensure the IDMixin is present (otherwise you will get ID type conflicts) and a standard set of schema annotations.

NOTE: you still have to make intelligent decisions around things like the presence / integration of hooks, interceptors, policies, etc. This is saving you about 10 seconds of copy-paste, so don't over estimate the automation, here.

To generate a new schema, you can run task newschema -- [yourschemaname] where you replace the name within []. Please be sure to note that this isn't a command line flag so there's a space between -- and the name.

Migrations

We use atlas and goose to create and manage our DB migrations - you can trigger one via task atlas:create and that will generate the necessary migrations. There should be a new migration file created in db/migrations and db/migrations-goose-postgres. On every PR, the Atlas integration also creates comments with any issues related to the schema changes / migrations.

Deploying

The only "supported" method of deploying today is locally, but we have a WIP Helm chart which can be found here

Contributing

See the contributing guide for more information

Documentation

Overview

package main is the entry point

Directories

Path Synopsis
cmd
Package cmd is our cobra cli implementation
Package cmd is our cobra cli implementation
cli
cli/cmd
Package cmd is the cobra cli implementation for the core server
Package cmd is the cobra cli implementation for the core server
cli/cmd/apitokens
Package apitokens is our cobra cli for api token endpoints
Package apitokens is our cobra cli for api token endpoints
cli/cmd/contact
Package contact is our cobra cli for contact endpoints
Package contact is our cobra cli for contact endpoints
cli/cmd/contacthistory
Package contacthistory is our cobra cli for contactHistory endpoints
Package contacthistory is our cobra cli for contactHistory endpoints
cli/cmd/documentdatahistory
Package documentdatahistory is our cobra cli for documentDataHistory endpoints
Package documentdatahistory is our cobra cli for documentDataHistory endpoints
cli/cmd/entitlementhistory
Package entitlementhistory is our cobra cli for entitlementHistory endpoints
Package entitlementhistory is our cobra cli for entitlementHistory endpoints
cli/cmd/entitlementplan
Package entitlementplan is our cobra cli for entitlement plan endpoints
Package entitlementplan is our cobra cli for entitlement plan endpoints
cli/cmd/entitlementplanfeaturehistory
Package entitlementplanfeaturehistory is our cobra cli for entitlementPlanFeatureHistory endpoints
Package entitlementplanfeaturehistory is our cobra cli for entitlementPlanFeatureHistory endpoints
cli/cmd/entitlementplanfeatures
Package entitlementplanfeatures is our cobra cli for plan feature endpoints
Package entitlementplanfeatures is our cobra cli for plan feature endpoints
cli/cmd/entitlementplanhistory
Package entitlementplanhistory is our cobra cli for entitlementPlanHistory endpoints
Package entitlementplanhistory is our cobra cli for entitlementPlanHistory endpoints
cli/cmd/entitlements
Package entitlement is our cobra cli for entitlement endpoints
Package entitlement is our cobra cli for entitlement endpoints
cli/cmd/entity
Package entity is our cobra cli for entity endpoints
Package entity is our cobra cli for entity endpoints
cli/cmd/entityhistory
Package entityhistory is our cobra cli for entityHistory endpoints
Package entityhistory is our cobra cli for entityHistory endpoints
cli/cmd/entitytype
Package entitytype is our cobra cli for entity type endpoints
Package entitytype is our cobra cli for entity type endpoints
cli/cmd/entitytypehistory
Package entitytypehistory is our cobra cli for entityTypeHistory endpoints
Package entitytypehistory is our cobra cli for entityTypeHistory endpoints
cli/cmd/eventhistory
Package eventhistory is our cobra cli for eventHistory endpoints
Package eventhistory is our cobra cli for eventHistory endpoints
cli/cmd/featurehistory
Package featurehistory is our cobra cli for featureHistory endpoints
Package featurehistory is our cobra cli for featureHistory endpoints
cli/cmd/features
Package feature is our cobra cli for feature endpoints
Package feature is our cobra cli for feature endpoints
cli/cmd/file
Package file is our cobra cli for file endpoints
Package file is our cobra cli for file endpoints
cli/cmd/filehistory
Package filehistory is our cobra cli for fileHistory endpoints
Package filehistory is our cobra cli for fileHistory endpoints
cli/cmd/group
Package group is our cobra cli for group endpoints
Package group is our cobra cli for group endpoints
cli/cmd/grouphistory
Package grouphistory is our cobra cli for groupHistory endpoints
Package grouphistory is our cobra cli for groupHistory endpoints
cli/cmd/groupmembers
Package groupmembers is our cobra cli for group member endpoints
Package groupmembers is our cobra cli for group member endpoints
cli/cmd/groupmembershiphistory
Package groupmembershiphistory is our cobra cli for groupMembershipHistory endpoints
Package groupmembershiphistory is our cobra cli for groupMembershipHistory endpoints
cli/cmd/groupsetting
Package groupsetting provides commands for managing group settings
Package groupsetting provides commands for managing group settings
cli/cmd/groupsettinghistory
Package groupsettinghistory is our cobra cli for groupSettingHistory endpoints
Package groupsettinghistory is our cobra cli for groupSettingHistory endpoints
cli/cmd/hushhistory
Package hushhistory is our cobra cli for hushHistory endpoints
Package hushhistory is our cobra cli for hushHistory endpoints
cli/cmd/integrationhistory
Package integrationhistory is our cobra cli for integrationHistory endpoints
Package integrationhistory is our cobra cli for integrationHistory endpoints
cli/cmd/invite
Package invite creates invitation emails + tokens for external users to join an organization
Package invite creates invitation emails + tokens for external users to join an organization
cli/cmd/login
Package login is our cobra cli for authentication endpoints
Package login is our cobra cli for authentication endpoints
cli/cmd/oauthproviderhistory
Package oauthproviderhistory is our cobra cli for oauthProviderHistory endpoints
Package oauthproviderhistory is our cobra cli for oauthProviderHistory endpoints
cli/cmd/organization
Package org is our cobra cli for organization endpoints
Package org is our cobra cli for organization endpoints
cli/cmd/organizationhistory
Package organizationhistory is our cobra cli for organizationHistory endpoints
Package organizationhistory is our cobra cli for organizationHistory endpoints
cli/cmd/organizationsetting
Package orgsetting provides commands for managing organization settings
Package orgsetting provides commands for managing organization settings
cli/cmd/organizationsettinghistory
Package organizationsettinghistory is our cobra cli for organizationSettingHistory endpoints
Package organizationsettinghistory is our cobra cli for organizationSettingHistory endpoints
cli/cmd/orgmembers
Package orgmembers is our cobra cli for org member endpoints
Package orgmembers is our cobra cli for org member endpoints
cli/cmd/orgmembershiphistory
Package orgmembershiphistory is our cobra cli for orgMembershipHistory endpoints
Package orgmembershiphistory is our cobra cli for orgMembershipHistory endpoints
cli/cmd/personalaccesstokens
Package tokens is our cobra cli for token endpoints
Package tokens is our cobra cli for token endpoints
cli/cmd/register
Package register allows user registration
Package register allows user registration
cli/cmd/reset
Package reset allows user password reset
Package reset allows user password reset
cli/cmd/search
Package search is our cobra cli for search endpoint
Package search is our cobra cli for search endpoint
cli/cmd/subscriber
Package subscribers is our cobra cli for subscriber endpoints
Package subscribers is our cobra cli for subscriber endpoints
cli/cmd/switchcontext
Package switchcontext provides a basic interface to switch between organization contexts
Package switchcontext provides a basic interface to switch between organization contexts
cli/cmd/templatehistory
Package templatehistory is our cobra cli for templateHistory endpoints
Package templatehistory is our cobra cli for templateHistory endpoints
cli/cmd/user
Package user is our cobra cli for user endpoints
Package user is our cobra cli for user endpoints
cli/cmd/userhistory
Package userhistory is our cobra cli for userHistory endpoints
Package userhistory is our cobra cli for userHistory endpoints
cli/cmd/usersetting
Package usersetting is our cobra cli for user setting endpoints
Package usersetting is our cobra cli for user setting endpoints
cli/cmd/usersettinghistory
Package usersettinghistory is our cobra cli for userSettingHistory endpoints
Package usersettinghistory is our cobra cli for userSettingHistory endpoints
cli/cmd/version
Package version contains the version information for the CLI
Package version contains the version information for the CLI
cli/cmd/webhookhistory
Package webhookhistory is our cobra cli for webhookHistory endpoints
Package webhookhistory is our cobra cli for webhookHistory endpoints
Package config holds configuration stuff to configure the things
Package config holds configuration stuff to configure the things
Package db provides an embedded filesystem containing all the database migrations
Package db provides an embedded filesystem containing all the database migrations
internal
constants
Package constants contains constants used throughout the application
Package constants contains constants used throughout the application
ent/customtypes
Package customtypes is a custom type definition for ent and the associated interfaces
Package customtypes is a custom type definition for ent and the associated interfaces
ent/entconfig
Package entconfig holds configuration stuff for the ent server
Package entconfig holds configuration stuff for the ent server
ent/generated
Code generated by entfga, DO NOT EDIT.
Code generated by entfga, DO NOT EDIT.
ent/hooks
Package hooks is middleware to alter the graphql mutation
Package hooks is middleware to alter the graphql mutation
ent/interceptors
Package interceptors is middleware to alter the graphql query
Package interceptors is middleware to alter the graphql query
ent/mixin
Package mixin contains the mixin package
Package mixin contains the mixin package
ent/privacy/rule
Package rule contains policy rules
Package rule contains policy rules
ent/privacy/token
Package token provides policy wrappers / getters for queries and mutations during password reset, sign-up
Package token provides policy wrappers / getters for queries and mutations during password reset, sign-up
ent/privacy/utils
Package utils is a helper for working with ent policies
Package utils is a helper for working with ent policies
ent/schema
Code generated by entx.history, DO NOT EDIT.
Code generated by entx.history, DO NOT EDIT.
entdb
Package entdb extends the ent db library and satisfies matt's needs for consistency
Package entdb extends the ent db library and satisfies matt's needs for consistency
graphapi
Package graphapi is the graph api package
Package graphapi is the graph api package
httpserve/authmanager
Package authmanager provides the authentication manager for the server
Package authmanager provides the authentication manager for the server
httpserve/config
Package config holds the echo server configuration utilities
Package config holds the echo server configuration utilities
httpserve/handlers
Package handlers contains custom handler functions
Package handlers contains custom handler functions
httpserve/route
Package route will hold the routes and route groups
Package route will hold the routes and route groups
httpserve/server
Package server contains the server functions
Package server contains the server functions
httpserve/serveropts
Package serveropts contains an echo server options wrapper
Package serveropts contains an echo server options wrapper
middleware/objects
package objects provides the customizations for the object upload middleware
package objects provides the customizations for the object upload middleware
pkg
enums
Package enums has enums
Package enums has enums
events/soiree
Package soiree provides a simple event emitter that allows you to emit events and listen for them
Package soiree provides a simple event emitter that allows you to emit events and listen for them
middleware
Package middleware provides middleware for http Handlers.
Package middleware provides middleware for http Handlers.
middleware/auth
Package auth handles auth
Package auth handles auth
middleware/authtest
Package authtest is a mini server and token generator with a mock test to confirm keygen works correctly; not intended to test the whole api but rather just the token issuance and authentication
Package authtest is a mini server and token generator with a mock test to confirm keygen works correctly; not intended to test the whole api but rather just the token issuance and authentication
middleware/cachecontrol
Package cachecontrol creates a cache control echo middleware
Package cachecontrol creates a cache control echo middleware
middleware/cors
Package cors does cors stuff
Package cors does cors stuff
middleware/debug
Package debug contains utility helper functions for debugging when working with echo server
Package debug contains utility helper functions for debugging when working with echo server
middleware/mime
Package mime does mime stuff
Package mime does mime stuff
middleware/ratelimit
Package ratelimit implements a rate limiting middleware
Package ratelimit implements a rate limiting middleware
middleware/ratelimiter
Package ratelimiter is a ratelimiter based on cloudflare's approach
Package ratelimiter is a ratelimiter based on cloudflare's approach
middleware/redirect
Package redirect does redirect stuff
Package redirect does redirect stuff
middleware/secure
Package secure is middleware that provides protection against cross-site scripting (XSS) attack, content type sniffing, clickjacking, insecure connection and other code injection attacks
Package secure is middleware that provides protection against cross-site scripting (XSS) attack, content type sniffing, clickjacking, insecure connection and other code injection attacks
middleware/transaction
Package transaction implements a transaction middleware for REST endpoints using the ent db client
Package transaction implements a transaction middleware for REST endpoints using the ent db client
models
Package models provides http request and response structs
Package models provides http request and response structs
objects
Package objects provides interfaces and helpers for management of objects (files) either received via our endpoints or created and stored by the system
Package objects provides interfaces and helpers for management of objects (files) either received via our endpoints or created and stored by the system
objects/storage
Package storage provides basic storage interfaces for storage providers to write / read objects to and from
Package storage provides basic storage interfaces for storage providers to write / read objects to and from
openlaneclient
Package openlaneclient contains the client to interact with the openlane server
Package openlaneclient contains the client to interact with the openlane server
registry
Package registry provides a basic jsonschema registry for creating / viewing jsonschema definitions
Package registry provides a basic jsonschema registry for creating / viewing jsonschema definitions
testutils
Package testutils provides utilities for use in tests
Package testutils provides utilities for use in tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL