I have setup keycloak server with all required configuration done like realm, client, users, roles etc. Now I have on angular application which is acting as frontend. Need to integrate this app with keycloak to provide authentication.
Angular app should redirect to Keycloak, Keycloak should do the user validation , Keycloak should provide access token after successful validation and finally angular app should be able to access spring boot API's with token provided by keycloak.
Typical OAuth2.0 Flow.
I am new to angular, so can anyone provide sample application code (github) for angular-keycloak integration. Also keycloak adapter for angular is required.
Keycloak version - 4.0.0.Final
Angular version - 1 but to be upgraded to 6
I am getting following error while downloading keycloak adapter for angular-
>npm install keycloak-angular#4.0.0.Final
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/keycloak-angular failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\40005928\AppData\Roaming\npm-cache\_logs\2019-07-11T11_42_38_802Z-debug.log.
Angular web application should be higher than 4.3 to integrate Keycloak.
Follow below steps to configure Keycloak:
1. Install Keycloak npm package
npm i keycloak-angular
2. Create app-init.ts file and add below contain:
import { KeycloakService } from 'keycloak-angular';
declare var keycloak : KeycloakService;
export function initializer(keycloak: KeycloakService): () => Promise<any> {
return (): Promise<any> => keycloak.init(
{
config: {
url: 'keycloak_URL',
realm: ''keycloak_ralm_name'',
clientId: 'keycloak_client_name'
},
initOptions: {
onLoad: 'login-required',
checkLoginIframe: false
},
enableBearerInterceptor: false
});}
Modify AppComponent file:
import { NgModule, APP_INITIALIZER } from '#angular/core';
import { KeycloakService, KeycloakAngularModule } from 'keycloak-angular';
import { initializer } from './app-init';
#NgModule({
imports: [KeycloakAngularModule],
providers: [
{
provide: APP_INITIALIZER,
useFactory: initializer,
multi: true,
deps: [KeycloakService]
}
]
})
For more information visit:
https://www.npmjs.com/package/keycloak-angular
Related
I using http-proxy-middleware to configure proxy for my react app. Everything is ok if I run my app in localhost. But when I deploy to heroku, netlify or firebase, my app have an error message "You need to enable JavaScript to run this app".
My code configure proxy in react app:
module.exports = app => {
app.use(
"/pool/.json",
createProxyMiddleware({
target: "https:myapi/api",
changeOrigin: true
})
);
};
My app only have that error message when I call this api.
I tried add proxy to package.json but still not working.
Note: I don't use expressJS for my server, my backend is available.
Sorry my english is pretty bad.
I'm currently facing an issue that i don't know anything about.
I'm building an app using Next.JS, TailwinCSS, Npm and vercel to deploy.
In fact, when i start the server, i'm having this issue (also when deploying on Vercel):
./node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[1]!./node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[2]!./node_modules/react-loader-spinner/dist/loader/css/react-spinner-loader.css
TypeError: Cannot read property 'theme' of undefined
at runMicrotasks (<anonymous>)
I had some issues at a time, with TailwindCSS because of certain properties not running, i don't know if the reinstallation had an impact or not...?
If someone have any idea,
Thank you for your time !
Replace
'#tailwindcss/jit': {}
with
tailwindcss: {}
in your postcss.config.js like
// https://tailwindcss.com/docs/using-with-preprocessors
module.exports = {
plugins: {
tailwindcss: {}, // remove '#tailwindcss/jit': {},
autoprefixer: {},
},
}
Then update tailwind.config.js and add
mode:'jit'
module.exports = {
mode:'jit', // <= add here
purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*. {js,ts,jsx,tsx}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
Also check this pr and issue
I was facing an similar issue.
My error log is following.
It was occured after updating packages.
> next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ./node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[6].use[1]!./node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[6].use[2]!./styles/globals.css
TypeError: Cannot read property 'theme' of undefined
I could not understand what happen.
So I do
rm -r node_modules
rm package-lock.json
rm -r .next
git reset --hard <commit id>
npm install
npm start
If that doesn't work, git clone again may work.
How about this?
Thanks!
I've created an application that gets all the data for various tables from static objects stored in their own files. I want to take these and move them onto Firebase so I can save my various data states. I'm really struggling to find a way to connect re-base and firebase together after multiple installs.
I get the error: TypeError: _base__WEBPACK_IMPORTED_MODULE_4__.base is undefined when I load my Loads module.
Here is my code for one of my components, note that LOADS is not my app component, could this be causing issues?
import {base} from '../../base';
class Loads extends Component{
constructor(props){
super(props);
this.state = {
tableData: null,
status: null
}
}
componentWillMount(){
this.loadDataRef = base.syncState('loadData', {
context: this,
state: 'loadData'
})
}
componentWillUnmount(){
base.removeBinding(this.loadDataRef);
}
Here is the code in base.js where I've imported firebase and rebase:
import Rebase from 're-base'
import firebase from 'firebase'
const config = {
apiKey: "this is a secret ;)",
authDomain: "yes",
databaseURL: "yes",
projectId: "yes",
storageBucket: "not sure",
messagingSenderId: "21",
appId: "yessir",
measurementId: "alright"
}
const app = firebase.initializeApp(config);
const base = Rebase.createClass(app.database());
export { base }
I've already done npm install --save re-base firebase, although I do get the following warnings:
npm WARN notsup Unsupported engine for firebase#7.14.3: wanted: {"node":"^8.13.0 || >=10.10.0"} (current: {"node":"8.10.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: firebase#7.14.3
npm WARN notsup Unsupported engine for #firebase/firestore#1.14.3: wanted: {"node":"^8.13.0 || >=10.10.0"} (current: {"node":"8.10.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: #firebase/firestore#1.14.3
npm WARN notsup Unsupported engine for #grpc/grpc-js#0.8.1: wanted: {"node":"^8.13.0 || >=10.10.0"} (current: {"node":"8.10.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: #grpc/grpc-js#0.8.1
Any help would be appreciated, I've been stuck here for a a day now looking at various ways of doing it but I can't seem to figure anything out.
Had issue while running the npm test
C:\projects\Test\node_modules\#aws-amplify\ui\dist\style.css:13:root {^
error:
SyntaxError: Unexpected token :
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/aws-amplify-react/src/Amplify-UI/Amplify-UI-Components-React.jsx:5:1)
here are my import statements
import Amplify from 'aws-amplify';
import { AuthPiece } from 'aws-amplify-react';
import { Auth, Logger, JS } from 'aws-amplify';
If I comment out the style.css it works without any errors.
But how can I remove this issue so that it doesnt cause issue to others when I commit code.
Had checked all the existing answers provided in different forums.But that doesnt work for me.
I ran into this problem as well, and this thread helped me resolve it. In my case, I needed to install identity-obj-proxy package and map it to the jest config:
npm install --save-dev identity-obj-proxy
package.json
"jest": {
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
}
}
I hope this helps!
Normally in angular.js I was used to consuming a web service GET, in which I passed 2 parameters, as follows.
$http.get('https://maps.googleapis.com/maps/api/geocode/json?latlng='+tweet.lat+','+tweet.long+'&key=AIzaSyBZVOSPh0Z4mv9jljJWzZNSug6upuec7Sg')
.then(function(result){
}, function(error){
}
How can I get this same result directly in nodejs?. thank you very much.
There are several way to do this. A lot of people use the request module, which makes things about the same as angular:
You'll need to install request (https://www.npmjs.com/package/request) with:
npm install request
and then:
var request = require('request');
request(url, function (error, response, body) {
// do stuff with response & body.
});
If you want promises, there is also a request-promise module available on npm (https://www.npmjs.com/package/request-promise).
npm install --save request
npm install --save request-promise
You need both request and request-promise in this case.
var request = require('request-promise');
request(url)
.then(function (result) {
// do stuff with result
})
.catch(function (err) {
//error
});
Also you can use the http module built into node, but then you'll need to manage the stream yourself.