I stuck in setting up a authorization.
I downloaded keycloak-3-2-1.Final and set up a new realm.
{
"realm": "proteomics",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required": "external",
"resource": "account",
"credentials": {
"secret": "696caa69-9259-45f5-a264-0d9da083f933"
},
"use-resource-role-mappings": true
}
Then I started a new angular project with 'ng new'. In this project I added keycloak-js npm install --save keyclak-js
My problem now is, how do I connect all these things together. On my header.component.html I want a single button to login (authenticate). Can anyone explain where and how I have to import keycloak-js and if anything else is missing, give me a hint to finish a simple login page?
app.compnent.ts
import { Component } from '@angular/core';
import { HeaderComponent } from './header/header.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
app.component.html
<app-header></app-header>
header.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
header.component.html
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a href="#" class="navbar-brand">ProtSkive</a>
</div>
<div class="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<button class="btn navbar-btn" id="login">Login</button>
</ul>
</div>
</div>
</nav>