Skip to content

Commit

Permalink
feat: make automate app registration optional based on the existence …
Browse files Browse the repository at this point in the history
…of the url config (#2094)

* feat: make automate app registration optional based on the existence of the url config

* docs: add back automate env var with docs

* feat: app redirect url application side override

* chore: cleanup
  • Loading branch information
gjedlicska authored Feb 29, 2024
1 parent edb1c63 commit b84b244
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 230 deletions.
7 changes: 6 additions & 1 deletion packages/server/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ STRATEGY_LOCAL=true
# FRONTEND_HOST=127.0.0.1
# FRONTEND_PORT=8081

SPECKLE_AUTOMATE_URL="http://127.0.0.1:3030"
############################################################
# Speckle automate related variables
# the env var is only needed if you are running the server and
# the execution engine locally
# SPECKLE_AUTOMATE_URL="http://127.0.0.1:3030"
############################################################
220 changes: 0 additions & 220 deletions packages/server/modules/auth/defaultApps.js

This file was deleted.

136 changes: 136 additions & 0 deletions packages/server/modules/auth/defaultApps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { Scopes } from '@/modules/core/helpers/mainConstants'
import { speckleAutomateUrl, getServerOrigin } from '@/modules/shared/helpers/envHelper'

const SpeckleWebApp = {
id: 'spklwebapp',
secret: 'spklwebapp',
name: 'Speckle Web Manager',
description:
'The Speckle Web Manager is your one-stop place to manage and coordinate your data.',
trustByDefault: true,
public: true,
redirectUrl: getServerOrigin(),
scopes: 'all'
}

const SpeckleApiExplorer = {
id: 'explorer',
secret: 'explorer',
name: 'Speckle Explorer',
description: 'GraphiQL Playground with authentication.',
trustByDefault: true,
public: true,
redirectUrl: new URL('/explorer', getServerOrigin()).toString(),
scopes: 'all'
}

const SpeckleDesktopApp = {
id: 'sdm',
secret: 'sdm',
name: 'Speckle Desktop Manager',
description:
'Manages local installations of Speckle connectors, kits and everything else.',
trustByDefault: true,
public: true,
redirectUrl: 'speckle://account',
scopes: [
Scopes.Streams.Read,
Scopes.Streams.Write,
Scopes.Profile.Read,
Scopes.Profile.Email,
Scopes.Users.Read,
Scopes.Users.Invite
]
}

const SpeckleConnectorApp = {
id: 'sca',
secret: 'sca',
name: 'Speckle Connector',
description: 'A Speckle Desktop Connectors.',
trustByDefault: true,
public: true,
redirectUrl: 'http://localhost:29363',
scopes: [
Scopes.Streams.Read,
Scopes.Streams.Write,
Scopes.Profile.Read,
Scopes.Profile.Email,
Scopes.Users.Read,
Scopes.Users.Invite
]
}

const SpeckleExcel = {
id: 'spklexcel',
secret: 'spklexcel',
name: 'Speckle Connector For Excel',
description:
'The Speckle Connector For Excel. For more info, check the docs here: https://speckle.guide/user/excel.',
trustByDefault: true,
public: true,
redirectUrl: 'https://speckle-excel.netlify.app',
scopes: [
Scopes.Streams.Read,
Scopes.Streams.Write,
Scopes.Profile.Read,
Scopes.Profile.Email,
Scopes.Users.Read,
Scopes.Users.Invite
]
}

const SpecklePowerBi = {
id: 'spklpwerbi',
secret: 'spklpwerbi',
name: 'Speckle Connector For PowerBI',
description:
'The Speckle Connector For Excel. For more info check the docs here: https://speckle.guide/user/powerbi.html.',
trustByDefault: true,
public: true,
redirectUrl: 'https://oauth.powerbi.com/views/oauthredirect.html',
scopes: [
Scopes.Streams.Read,
Scopes.Profile.Read,
Scopes.Profile.Email,
Scopes.Users.Read,
Scopes.Users.Invite
]
}

const SpeckleAutomate = {
id: 'spklautoma',
secret: 'spklautoma',
name: 'Speckle Automate',
description: 'Our automation platform',
trustByDefault: true,
public: true,
redirectUrl: `${speckleAutomateUrl()}/authn/callback`,
scopes: [
Scopes.Profile.Email,
Scopes.Profile.Read,
Scopes.Users.Read,
Scopes.Tokens.Write,
Scopes.Streams.Read,
Scopes.Streams.Write,
Scopes.Automate.ReportResults
]
}

const defaultApps = [
SpeckleWebApp,
SpeckleApiExplorer,
SpeckleDesktopApp,
SpeckleConnectorApp,
SpeckleExcel,
SpecklePowerBi,
SpeckleAutomate
]

export function getDefaultApps() {
return defaultApps
}

export function getDefaultApp({ id }: { id: string }) {
return defaultApps.find((app) => app.id === id) || null
}
2 changes: 1 addition & 1 deletion packages/server/modules/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ exports.init = async (app) => {
exports.finalize = async () => {
// Note: we're registering the default apps last as we want to ensure that all
// scopes have been registered by any other modules.
await require('./defaultApps')()
await require('./manageDefaultApps')()
}
Loading

0 comments on commit b84b244

Please sign in to comment.