All Projects → iuliazidaru → keycloak-spring-boot-rest-angular-demo

iuliazidaru / keycloak-spring-boot-rest-angular-demo

Licence: other
Demo for configuring Keycloak authentication for a spring-boot rest service and AngularJs web client

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to keycloak-spring-boot-rest-angular-demo

angular6-httpclient-example
Angular 6 HttpClient: Consume RESTful API Example
Stars: ✭ 38 (+58.33%)
Mutual labels:  angularjs
angular-downloader
Angular Downloader is an angularjs directive that enables you to manage browser download - https://720kb.github.io/angular-downloader
Stars: ✭ 16 (-33.33%)
Mutual labels:  angularjs
angular2-trim-directive
the directive trims whitespaces from the end of an input text value.
Stars: ✭ 45 (+87.5%)
Mutual labels:  angularjs
apollobank
A full stack GraphQL banking application using React, Node & TypeScript.
Stars: ✭ 203 (+745.83%)
Mutual labels:  cors
keycloakify-demo-app
Demo GitHub Actions setup for react projects that uses keycloakify
Stars: ✭ 34 (+41.67%)
Mutual labels:  keycloak
steam-openid-connect-provider
Steam OpenID Connect Identity Provider (IdP)
Stars: ✭ 40 (+66.67%)
Mutual labels:  keycloak
js-sdk
JavaScript frontend SDK for ConfigCat. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
Stars: ✭ 21 (-12.5%)
Mutual labels:  angularjs
vogon-java
Vogon - A simple personal finance tracker using Spring Boot and AngularJS
Stars: ✭ 16 (-33.33%)
Mutual labels:  angularjs
smartcitizen-web
The Smart Citizen Kit platform
Stars: ✭ 13 (-45.83%)
Mutual labels:  angularjs
brush
An amazing scaffolding for developing database-driven websites, applications and APIs. Built on Laravel Lumen Framework, MySQL and Angular.
Stars: ✭ 23 (-4.17%)
Mutual labels:  angularjs
front-end-notes
前端课程学习笔记汇总
Stars: ✭ 57 (+137.5%)
Mutual labels:  angularjs
laravel5Angular4
Laravel 5.4 & Angular 4.3.4
Stars: ✭ 37 (+54.17%)
Mutual labels:  angularjs
popmovies-web
Starter project using nodejs expressjs and angular 2
Stars: ✭ 17 (-29.17%)
Mutual labels:  angularjs
spid-keycloak-provider
Italian SPID authentication provider for Keycloak (https://www.keycloak.org/)
Stars: ✭ 48 (+100%)
Mutual labels:  keycloak
keycloak-kubernetes
Keycloak deployment into Kubernetes cluster
Stars: ✭ 25 (+4.17%)
Mutual labels:  keycloak
Natours
An awesome tour booking web app written in NodeJS, Express, MongoDB 🗽
Stars: ✭ 94 (+291.67%)
Mutual labels:  cors
terraform-aws-api-gateway-enable-cors
Easily add an OPTIONS method to an API Gateway resource to enable CORS
Stars: ✭ 56 (+133.33%)
Mutual labels:  cors
angular
Repository for my tutorial course: Learning AngularJS on LinkedIn Learning and Lynda.com. http://raybo.org/angular
Stars: ✭ 79 (+229.17%)
Mutual labels:  angularjs
angular-spa-demo
Demo code for a Single Page Application using AngularJS
Stars: ✭ 20 (-16.67%)
Mutual labels:  angularjs
e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (+100%)
Mutual labels:  keycloak

keycloak-spring-boot-rest-angular-demo

Demo for configuring Keycloak authentication for a spring-boot rest service and AngularJs web client

Prerequisite

  • Keycloack (1.1.0) server installed
  • Java (1.8)
  • Maven (3.2.2)
  • Source code

Setup

  1. Clone https://github.com/iuliazidaru/keycloak-spring-boot-rest-angular-demo

  2. Download keycloak-appliance-dist-all-1.1.0.final.zip (or later version).

Start keycloack and import the realm provided with the source code.

  1. Start the rest server:

mvn spring-boot:run 4. Start the angular application

mvn spring-boot:run 5. Go to localhost:7005 and login using user/pass.

  1. Press reload to create a hello-world request to server.

Configuration

As all three applications run on different domains, we have to configure CORS.

Enable CORS in rest project

In keycloak.json a new line has to be added:

"enable-cors": true Also, CORSFilter has to be added in order to provide required headers for XMLHttpRequests.

https://github.com/iuliazidaru/keycloak-spring-boot-rest-angular-demo/blob/master/rest/src/main/java/hello/SimpleCORSFilter.java

AngularJS project configuration

The application must be public. Also, configure the web origin and the matching redirect URL.

Spring Security Context

In some cases we may need to access the user in context. Keycloak configuration is configured at container level, so Spring Security filters cannot be used.

Add security context dependency in order to have SpringContextHolder class. Do not use spring-boot-security as then the web application will be secure by default with ‘basic’ authentication on all HTTP endpoints.

We can add a simple HttpFilter which sets the securityContext:

https://github.com/iuliazidaru/keycloak-spring-boot-rest-angular-demo/blob/master/rest/src/main/java/hello/AuthenticationFilter.java

Tests

For writing integration tests we need Kecloak's Direct Access API.

https://github.com/iuliazidaru/keycloak-spring-boot-rest-angular-demo/blob/master/rest/src/test/java/hello/HelloWorldConfigurationTests.java

Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].