View graphback-keycloak-auth-extend.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { KeycloakCrudService } from '@graphback/keycloak-authz' | |
class CustomCrudService extends KeycloakCrudService { | |
// custom implementation | |
} | |
const services = createKeycloakRuntimeContext({ | |
models, | |
schema: model, | |
db, |
View graphback-keycloak-auth-runtime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloServer } from 'apollo-server-express' | |
import { createKeycloakRuntimeContext } from '@graphback/keycloak-authz' | |
import { GraphbackRuntime } from 'graphback' | |
import { KnexDbDataProvider } from '@graphback/runtime-knex' | |
import { PubSub } from 'graphql-subscriptions' | |
import * as Knex from 'knex' | |
import { printSchema } from 'graphql' | |
// the application model | |
const model = ` |
View graphback-keycloak-authz-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authConfig = { | |
Task: { | |
create: {}, | |
read: {}, | |
update: { roles: ["admin"] }, | |
delete: { roles: ["admin"] } | |
}, | |
Report: { | |
create: { roles: ["admin"] }, | |
read: {}, |
View aws_schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input CreateNoteInput { | |
id: ID | |
content: String! | |
_version: Int | |
} | |
input CreateTaskInput { | |
id: ID | |
title: String! | |
description: String |
View client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloOfflineClient } from 'offix-client'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import { HttpLink } from "apollo-link-http"; | |
const config = { | |
link: new HttpLink({ uri: 'http://example.com/graphql' }) | |
cache: new InMemoryCache() | |
}; |
View keycloak-apollo-client-subscriptions-setup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Keycloak from 'keycloak-js' | |
import { WebSocketLink } from 'apollo-link-ws' | |
var keycloak = Keycloak({ | |
url: 'http://keycloak-server/auth', | |
realm: 'myrealm', | |
clientId: 'myapp' | |
}) |
View keycloak-connect-graphql-subscriptions-resolvers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
Subscription: { | |
commentAdded: { | |
subscribe: () => pubsub.asyncIterator(COMMENT_ADDED) | |
}, | |
messageAdded: { | |
subscribe: auth(() => pubsub.asyncIterator(COMMENT_ADDED)) | |
}, | |
alertAdded: { | |
subscribe: hasRole('admin')(() => pubsub.asyncIterator(ALERT_ADDED)) |
View keycloak-connect-graphql-subscriptions-setup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keycloakSubscriptionHandler = new KeycloakSubscriptionHandler({ keycloak }) | |
new SubscriptionServer({ | |
execute, | |
subscribe, | |
schema: server.schema, | |
onConnect: async (connectionParams, websocket, connectionContext) => { | |
const token = await keycloakSubscriptionHandler.onSubscriptionConnect(connectionParams) | |
return { | |
kauth: new KeycloakSubscriptionContext(token) | |
} |
View keycloak-connect-graphql-middlewares-example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { auth, hasRole } = require('keycloak-connect-graphql') | |
const resolvers = { | |
Article: { | |
analytics: hasRole('editor')(articleAnalyticsResolver) | |
}, | |
Query: { | |
listArticles: auth(listArticlesResolver) | |
}, | |
mutation: { |
View keycloak-connect-graphql-directives-example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const typeDefs = gql` | |
type Article { | |
id: ID! | |
title: String! | |
content: String! | |
} | |
type Query { | |
listArticles: [Article]! @auth | |
} |
NewerOlder