bob
05/19/2020, 7:48 AMtypeDefs: [KeycloakTypeDefs, "./src/schema.graphql"],
schemaDirectives: KeycloakSchemaDirectives,
KeycloakTypeDefs or KeycloakSchemaDirectives
im not sure which one, comes with an @auth
type but i dont know how to use it in my schema fileLuís Almeida
05/19/2020, 8:27 AMbob
05/19/2020, 8:28 AMLuís Almeida
05/19/2020, 8:30 AMbob
05/19/2020, 8:33 AMbob
05/19/2020, 9:06 AMLuís Almeida
05/19/2020, 9:07 AMbob
05/19/2020, 9:10 AMbob
05/19/2020, 9:11 AMLuís Almeida
05/19/2020, 9:24 AMconst keycloak = new Keycloak({ scope: 'openid' });
bob
05/19/2020, 9:25 AMLuís Almeida
05/19/2020, 9:25 AMconst server = new GraphQLServer({
typeDefs: [typeDefs, KeycloakTypeDefs],
schemaDirectives: KeycloakSchemaDirectives,
resolvers,
context: ({ request }) => {
return {
kauth: new KeycloakContext({ req: request }),
};
},
});
Luís Almeida
05/19/2020, 9:25 AMLuís Almeida
05/19/2020, 9:25 AMbob
05/19/2020, 9:28 AMLuís Almeida
05/19/2020, 9:29 AMbob
05/19/2020, 9:29 AMLuís Almeida
05/19/2020, 9:32 AMbob
05/19/2020, 9:43 AMLuís Almeida
05/19/2020, 9:44 AMbob
05/19/2020, 9:44 AMbob
05/19/2020, 9:58 AMLuís Almeida
05/19/2020, 9:58 AMbob
05/19/2020, 9:59 AM{
"realm": "PakZe",
"bearer-only": true,
"auth-server-url": "<http://localhost:8080/auth/>",
"ssl-required": "external",
"resource": "PakzeApi",
"confidential-port": 0
}
Luís Almeida
05/19/2020, 10:00 AMLuís Almeida
05/19/2020, 10:01 AMLuís Almeida
05/19/2020, 10:01 AMbob
05/19/2020, 10:01 AMbob
05/19/2020, 10:04 AMLuís Almeida
05/19/2020, 10:05 AMbob
05/19/2020, 10:05 AMLuís Almeida
05/19/2020, 10:05 AMLuís Almeida
05/19/2020, 10:09 AMLuís Almeida
05/19/2020, 10:10 AMbob
05/19/2020, 10:45 AMLuís Almeida
05/19/2020, 11:04 AMbob
05/19/2020, 11:16 AMexports.auth = (next) => (root, args, context, info) => {
if (!context[KeycloakContext_1.CONTEXT_KEY] || !context[KeycloakContext_1.CONTEXT_KEY].isAuthenticated()) {
`const error = new Error(User not Authenticated
);`
error.code = "UNAUTHENTICATED";
throw error;
}
return next(root, args, context, info);
};
Luís Almeida
05/19/2020, 11:20 AMnode_modules/keycloak-connect/middleware/grant-attacher.js
Luís Almeida
05/19/2020, 11:20 AMnode_modules/keycloak-connect/keycloak.js line 306
Luís Almeida
05/19/2020, 11:20 AMbob
05/19/2020, 11:22 AMLuís Almeida
05/19/2020, 11:23 AMnode_modules/keycloak-connect/
Luís Almeida
05/19/2020, 11:23 AMLuís Almeida
05/19/2020, 11:23 AMbob
05/19/2020, 11:23 AMLuís Almeida
05/19/2020, 11:23 AMKeycloak.prototype.getGrant
bob
05/19/2020, 11:23 AMLuís Almeida
05/19/2020, 11:24 AMbob
05/19/2020, 11:24 AMbob
05/19/2020, 11:29 AMbob
05/19/2020, 11:29 AM/*! ignore */
Keycloak.prototype.getGrant = function (request, response) {
console.log("test")
var rawData;
for (var i = 0; i < this.stores.length; ++i) {
rawData = this.stores[i].get(request);
if (rawData) {
// store = this.stores[i];
break;
}
}
var grantData = rawData;
if (typeof (grantData) === 'string') {
grantData = JSON.parse(grantData);
}
if (grantData && !grantData.error) {
var self = this;
return this.grantManager.createGrant(JSON.stringify(grantData))
.then(grant => {
self.storeGrant(grant, request, response);
return grant;
})
.catch(() => { return Promise.reject(new Error('Could not store grant code error')); });
}
return Promise.reject(new Error('Could not obtain grant code error'));
};
Luís Almeida
05/19/2020, 11:30 AMbob
05/19/2020, 11:32 AMbob
05/19/2020, 11:33 AMLuís Almeida
05/19/2020, 11:34 AMLuís Almeida
05/19/2020, 11:35 AMbob
05/19/2020, 11:43 AMbob
05/19/2020, 11:46 AMLuís Almeida
05/19/2020, 11:46 AMbob
05/19/2020, 11:47 AMLuís Almeida
05/19/2020, 11:50 AMKeycloak.prototype.middleware
bob
05/19/2020, 12:12 PMLuís Almeida
05/19/2020, 12:41 PMLuís Almeida
05/19/2020, 12:43 PM