Closed stuartbloom closed 6 years ago
Yes, that would be possible.
@shaunluttin Thant's great, would you have an example?
Hmm. I don't have an example of that off the top of my head. I've been away from this project for some time now. We can chat about it in this issue, and you'll need to do a lot of the leg work yourself while I can guide you in the right direction.
On application startup, to forward the app to the authorization service, you will need to trigger this:
public login(instruction: NavigationInstruction): Promise<any> {
let args: any = {};
return this.userManager.signinRedirect(args);
}
That is exactly what the existing login route does.
private addLoginRoute(routerConfiguration: RouterConfiguration) {
routerConfiguration.mapRoute({
name: "login",
nav: false,
navigationStrategy: (instruction: NavigationInstruction) => {
instruction.config.redirect = "";
return this.openIdConnectNavigationStrategies.login(instruction);
},
route: "login",
settings: {
roles: [
OpenIdConnectRoles.Anonymous,
],
},
});
}
So, you need with to call openIdConnectNavigationStrategies.login(instruction)
directly or trigger the configured login route.
Does that make sense?
Thanks, away from desk at the moment, but will have a play after the weekend, have a good one ;)
Something like this? (in app.js) and place the aurelia stuff in a div, instead of body. usermanager adds an iframe, which it needs to check the session.
so like this:
<body>
<div aurelia-app="main"></div>
<script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
</body>
import { inject } from 'aurelia-dependency-injection';
import oidcConfig from "./open-id-connect-configuration";
import { OpenIdConnect, OpenIdConnectRoles } from "aurelia-open-id-connect";
@inject(OpenIdConnect)
export class App {
constructor(openIdConnect) {
let self = this;
this.openIdConnect = openIdConnect;
let mgr = self.openIdConnect.userManager;
self.openIdConnect.userManager.getUser().then((user) => {
if (user) {
mgr.querySessionStatus().then(
function () {
self._loadUserDetails(user);
},
function () {
mgr.removeUser();
}
);
}
else {
mgr.signinSilent().then(function (user) {
self._loadUserDetails(user);
}, function () {
mgr.signinRedirect({});
});
}
});
self.openIdConnect.userManager.events.addUserLoaded(() => {
self.openIdConnect.userManager.getUser().then((user) => {
self._loadUserDetails(user);
});
});
}
_loadUserDetails(user) {
this.user = user;
}
Thank-you @AndreSteenbergen for that.
You're welcome
Op 7 jun. 2017 19:38 schreef "Shaun Luttin" notifications@github.com:
Thank @AndreSteenbergen https://github.com/andresteenbergen for that.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shaunluttin/aurelia-open-id-connect/issues/25#issuecomment-306869746, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUjdk7KAhhln8kD05CG21yf14xPa1Kfks5sBuASgaJpZM4MtFdS .
Hi there, and thank you for this plugin.
Although I am getting compilation errors when running the cloned demo, I am able to get it to connect ot my token server and make api calls :)
Just wondering; is it possible to use the plugin and forward the application to the token server when the application starts?
Thanks again