rafaelcascalho / keycloak-middleware-ts Goto Github PK
View Code? Open in Web Editor NEWKeycloakd middleware to simply use keycloak validation and verifications.
License: MIT License
Keycloakd middleware to simply use keycloak validation and verifications.
License: MIT License
When trying to inject an axios
configuration in the request
parameter in the createKeycloakCtx
function, a typing error is returned, saying that the post method is not a function, as in the example below...
Steps to reproduce the behavior:
axios
configuration following AxiosInstance
typingWill return a typing error showing that the post is not a function
Example:
[Nest] 16436 - 17/02/2022 16:35:44 ERROR [UserService] TypeError: this.request.post is not a function
TypeError: this.request.post is not a function
at AccessToken.<anonymous> (C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\AccessToken.js:69:49)
at Generator.next (<anonymous>)
at C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\AccessToken.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\AccessToken.js:4:12)
at AccessToken.get (C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\AccessToken.js:55:16)
at UserManager.<anonymous> (C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\UserManager.js:83:50)
at Generator.next (<anonymous>)
at C:\Users\example\www\nestjs-project\node_modules\keycloak-middleware-ts\lib\UserManager.js:8:71
at new Promise (<anonymous>)
Versions:
Additional context
Below is an example of configuration and use of the library where this problem occurs
import createKeycloakCtx from 'keycloak-middleware-ts';
import dotenv from 'dotenv';
import qs from 'qs';
dotenv.config();
export const {
KEYCLOAK_REALM,
KEYCLOAK_URL,
KEYCLOAK_CLIENT_ID,
KEYCLOAK_CLIENT_SECRET,
KEYCLOAK_USERNAME,
KEYCLOAK_PASSWORD,
KEYCLOAK_JWT_KEY,
} = process.env;
const axiosConfig = {
config: {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: qs.stringify({
grant_type: 'password',
clientId: KEYCLOAK_CLIENT_ID,
clientSecret: KEYCLOAK_CLIENT_SECRET,
username: KEYCLOAK_USERNAME,
password: KEYCLOAK_PASSWORD,
}),
},
};
export const keycloak = createKeycloakCtx(
{
realm: KEYCLOAK_REALM,
authServerUrl: KEYCLOAK_URL,
clientId: KEYCLOAK_CLIENT_ID,
clientSecret: KEYCLOAK_CLIENT_SECRET,
username: KEYCLOAK_USERNAME,
password: KEYCLOAK_PASSWORD,
jwtKey: KEYCLOAK_JWT_KEY,
jwtKeyAlgorithms: ['RS256'],
},
axiosConfig,
);
await keycloak.users
.create({
firstName: 'John',
lastName: 'Doe',
username: 'john_doe',
email: '[email protected]',
enabled: true,
password: 'str0ng-p4ss',
});
I want to add attributes to an user since, for each user, I need to identify them with things like country, phone, etc.
In the documentation, the installation instruction is not right
In the document README.md it shows the instruction to install the library, but it is not published like this in NPM.
npm install -S keycloak-backend-ts
To Reproduce
Steps to reproduce the behavior:
What to do?
Just change the package name according to what was published in NPM
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.