Skip to content

Instantly share code, notes, and snippets.

import { Observable } from 'rxjs/Observable';
import { KeycloakApiService } from './keycloak/keycloak-api.service';
import { IsLoggedInCheck } from './keycloak/keycloak.actions';
import { selectKeycloakModel } from './keycloak/keycloak.reducer';
import { AppState } from './reducers';
import { Store } from '@ngrx/store';
import { Injectable } from '@angular/core';
import {
CanActivate, Router,
ActivatedRouteSnapshot,
import { Observable } from 'rxjs/Observable';
import { KeycloakApiService } from '../keycloak/keycloak-api.service';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
@Injectable()
export class CustomHttp {
private apiBaseUrl = `Your API Endpoint`;
import {
StoreModule,
ActionReducerMap,
MetaReducer,
createFeatureSelector,
createSelector
} from '@ngrx/store';
import { Params, RouterStateSnapshot } from '@angular/router';
import { compose } from '@ngrx/store';
import { ActionReducer, combineReducers } from '@ngrx/store';
export interface KeycloakModel {
readonly isLoggedIn: boolean;
readonly showLoading: boolean;
readonly id: string;
readonly needsLogin: boolean;
}
export interface KeycloakLoginCheckResponse {
loggedIn: boolean;
idmId: string;
import { AppState } from '../reducers';
/* tslint:disable: no-switch-case-fall-through */
import { Action } from '@ngrx/store';
import { KeycloakActions, KeycloakActionTypes, LoginSuccess } from './keycloak.actions';
import { KeycloakModel } from './keycloak.model';
export interface KeycloakState {
keycloakModel: KeycloakModel;
checkingKeycloakStatus: boolean;
import { KeycloakActionTypes, IsLoggedInCheckSuccess, LoginSuccess } from './keycloak.actions';
import { KeycloakApiService } from './keycloak-api.service';
/* tslint:disable: member-ordering */
import { Injectable } from '@angular/core';
import { Actions, Effect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import {
IsLoggedInCheck
import { KeycloakLoginCheckResponse } from './keycloak.model';
import { Response } from '@angular/http';
import { Action } from '@ngrx/store';
export enum KeycloakActionTypes {
IsLoggedInCheck = '[Keycloak] Is Loggedin Check',
IsLoggedInCheckSuccess = '[Keycloak] Is Logged In Check Success',
IsLoggedInCheckFail = '[Keycloak] Is Logged In Check Fail',
Login = '[Keycloak] Login',
LoginSuccess = '[Keycloak] Login Success',
import { KeycloakLoginCheckResponse } from './../keycloak/keycloak.model';
import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import './keycloak';
import { Observer } from 'rxjs/Observer';
declare const Keycloak: any;
@Injectable()
export class KeycloakApiService {
{
"realm": "name of the realm",
"auth-server-url": "keycloak authorization endpoint",
"ssl-required": "external",
"resource": "name of the resource",
"public-client": true,
"use-resource-role-mappings": true
}
<script type="text/javascript"
src="<%= htmlWebpackPlugin.options.keycloakUrl %>/auth/js/keycloak.min.js"></script>