How to use @aerogear/voyager-keycloak - 2 common examples

To help you get started, we’ve selected a few @aerogear/voyager-keycloak examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerogear / ionic-showcase / server / src / index.js View on Github external
const { appTypeDefs, appResolvers } = require('./schema')
const agSender = require("unifiedpush-node-sender")

process.on('unhandledRejection', error => {
  console.error('unhandledRejection', error.message);
  process.exit(1);
});

let keycloakService = null
let pushClient = null

// if a keycloak config is present we create
// a keycloak service which will be passed into
// ApolloVoyagerServer
if (config.keycloakConfig) {
  keycloakService = new KeycloakSecurityService(config.keycloakConfig)
}

if (config.pushConfig) {
  let pushService = agSender(config.pushConfig)
  pushClient = pushService.then((client) => {
    return client;
  })
}

async function start() {

  const app = express()

  app.use(cors())
  metrics.applyMetricsMiddlewares(app, {
    path: '/metrics'
github aerogear / datasync / examples / keycloak / server.js View on Github external
// Resolver functions. This is our business logic
const resolvers = {
  Query: {
    hello: (obj, args, context, info) => {
      // log some of the auth related info added to the context
      console.log(context.auth.isAuthenticated())
      console.log(context.auth.accessToken.content.name)

      const name = context.auth.accessToken.content.name || 'world'
      return `Hello ${name} from ${context.serverName}`
    }
  }
}

// Initialize the keycloak service
const keycloakService = new KeycloakSecurityService(keycloakConfig)

// The context is a function or object that can add some extra data
// That will be available via the `context` argument the resolver functions
const context = ({ req }) => {
  return {
    serverName: 'Voyager Server'
  }
}

// Initialize the voyager server with our schema and context

const apolloConfig = {
  typeDefs: [typeDefs, keycloakService.getTypeDefs()],
  resolvers,
  context
}

@aerogear/voyager-keycloak

Adds Keycloak authentication and authorization to Voyager Server

Apache-2.0
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis

Popular @aerogear/voyager-keycloak functions