Skip to content
Snippets Groups Projects
Select Git revision
  • ci-update
  • main default
  • keycloak-deprecate
  • remove-jwt-easy
  • v0.1.15
  • v0.1.14
  • v0.1.13
  • v0.1.12
  • v0.1.11
  • v0.1.10
  • v0.1.9
  • v0.1.8
  • v0.1.7
  • v0.1.6
  • v0.1.5
  • v0.1.4
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
20 results

LocalTokenValidatorTest.php

Blame
    • Reiter, Christoph's avatar
      3faa7dd5
      Switch to the OIDC discover protocol for the provider config · 3faa7dd5
      Reiter, Christoph authored
      The goal is to support every OIDC server that implements the discover
      protocol (Keycloak for example). This allows us to fetch all the required
      information at runtime without the user having to keep the settings
      in sync with the used server. The config and public keys are cached for
      one hour.
      
      While in theory this works with non-keycloak it isn't tested yet, and we
      still need keycloak specific settings for the API docs auth because we only
      support keycloak with our frontend web components which we inject into the
      openapi docs.
      
      Fixes #3
      3faa7dd5
      History
      Switch to the OIDC discover protocol for the provider config
      Reiter, Christoph authored
      The goal is to support every OIDC server that implements the discover
      protocol (Keycloak for example). This allows us to fetch all the required
      information at runtime without the user having to keep the settings
      in sync with the used server. The config and public keys are cached for
      one hour.
      
      While in theory this works with non-keycloak it isn't tested yet, and we
      still need keycloak specific settings for the API docs auth because we only
      support keycloak with our frontend web components which we inject into the
      openapi docs.
      
      Fixes #3
    rollup.utils.js 2.37 KiB
    import path from 'path';
    import url from 'url';
    import fs from 'fs';
    import child_process from 'child_process';
    import resolve from '@rollup/plugin-node-resolve';
    import selfsigned from 'selfsigned';
    import findCacheDir from 'find-cache-dir';
    
    export function getBuildInfo(build) {
        let remote = child_process.execSync('git config --get remote.origin.url').toString().trim();
        let commit = child_process.execSync('git rev-parse --short HEAD').toString().trim();
    
        let parsed = url.parse(remote);
        let newPath = parsed.path.slice(0, parsed.path.lastIndexOf('.'));
        let newUrl = parsed.protocol + '//' + parsed.host + newPath + '/commit/' + commit;
    
        return {
            info: commit,
            url: newUrl,
            time: new Date().toISOString(),
            env: build
        }
    }
    
    export async function getDistPath(packageName, assetPath) {
        if (assetPath === undefined)
            assetPath = '';
        // make sure the package exists to avoid typos
        await getPackagePath(packageName, '');
        return path.join('local', packageName, assetPath);
    }
    
    export async function getPackagePath(packageName, assetPath) {
        const r = resolve();
        const resolved = await r.resolveId(packageName);
        let packageRoot;
        if (resolved !== null) {
            const id = (await r.resolveId(packageName)).id;
            const packageInfo = r.getPackageInfoForId(id);
            packageRoot = packageInfo.root;
        } else {
            // Non JS packages
            packageRoot = path.dirname(require.resolve(packageName + '/package.json'));
        }
        return path.relative(process.cwd(), path.join(packageRoot, assetPath));
    }
    
    /**
     * Creates a dummy dev server certificate, caches it and returns it.
     */
    export async function generateTLSConfig() {
        const certDir = findCacheDir({name: 'dbp-dev-server-cert'});
        const keyPath = path.join(certDir, 'server.key');
        const certPath = path.join(certDir, 'server.cert');
    
        await fs.promises.mkdir(certDir, {recursive: true});
    
        if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
            const attrs = [{name: 'commonName', value: 'dbp-dev.localhost'}];
            const pems = selfsigned.generate(attrs, {algorithm: 'sha256', days: 9999});
            await fs.promises.writeFile(keyPath, pems.private);
            await fs.promises.writeFile(certPath, pems.cert);
        }
    
        return {
            key: await fs.promises.readFile(keyPath),
            cert: await fs.promises.readFile(certPath)
        }
    }