scottbrady91 / angular4-oidcclientjs-example Goto Github PK
View Code? Open in Web Editor NEWCode from scottbrady91.com/Angular
Code from scottbrady91.com/Angular
Hi
How can we add the router parameters into redirect_uri is it possible to do?
Protected-Page and API are still accessible after logging out from identity server!
Any Ideas or solutions? :)
I am following
https://www.scottbrady91.com/Angular/SPA-Authentiction-using-OpenID-Connect-Angular-CLI-and-oidc-client and https://www.scottbrady91.com/Angular/Migrating-oidc-client-js-to-use-the-OpenID-Connect-Authorization-Code-Flow-and-PKCE to implement OIDC in SPA(Angular)
I am using aspboilerplate integrated IdentityServer
I've set up everything as per the above articles and I was able to navigate to external auth provider and was also able to enter the required credentials.
While redirecting to angular I am getting 400 - Bad request. Here are the details
Call back URL :
http://localhost:4200/auth-callback?code=b74f38054d4becadaa3c45ce58a83c892e0d25e7fc4bfcc1ef29ce369b477596&scope=openid%20profile%20api1&state=18af0415b22b4614882d3e31113e2717&session_state=yP4rCdCetarKTsX6X0JXYTeV_1Xo8dud9V2FnT-14QE.db913b7a39e26220d8ac07de5a523eb2
Cookies :
Request sent 9095 bytes of Cookie data:
.AspNetCore.Antiforgery.xkdte50z5pg=CfDJ8FAKJpEizERFtUzdjBClgctpGC-BWtg81DZ33kUapCDBb84U7ILfbqhExQzI3oVOWReKh72cV8hdROZcCh6wK7tbwl14PnWzNIECZGxyYx-K3MINQnZEp3cp-Ury1Z4KaRHs7mqvmf6oc30h6Q-oFxI
idsrv.external=chunks-2
idsrv.externalC1=CfDJ8FAKJpEizERFtUzdjBClgcum3jNb_Pj5sm5cfWLtKGcBqkU1VIUHlMdupOgnYwqTNw3bjxOoeVbCR1YR9y6Y2Q6zZvxX2juNv1iiUTwVIcTAG99R0QU8Ki1EJ8uOvaVN-BgUFNXYzcrct69nxfTGj5Ay2wL18-ziLczxnqurAbgTVkgyZs6IWHgtbOwyoyJb3klbQUkt4nmNZbwNSzeYknhDq7ohwEqeva51TIw73lciD2bJpJZnxUFx9eRI7FiJcf6qM3iYzvQ9R1-IRAmT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UwyflpCcTItrhy57-IJbHujRVosl8x6s2A9J_JytTK9y4lqfBe38h6dQtPNOdjhkA_ioWdvWn2KFVLtULnapFScWLm4ew-Gbrxfrmj68JzmsKUOKmm6i0o2Y0JMEg9gsExTh1K3Z_e_DCnfJl3XGgB6Q5rX_qzcvqwyldPn1xJyXealA5KCi38hqsI0wy5-LZhiIUt6PEQX_WNF5wiL9jkT_6-qVfUhlRB87tcqx6YHwdwlYUErsNkrRwZJQrtXxDJoZwEWYy31Ehpi2XVoKTksNGdvHbJcPtFBt7BactgMy6MRu0LVTI8XFhVaG-9LaiHAq9U3c2vblpNjdlBW0nrujZo5MaV5xroyrL3PxZ3j9oj3FzbtgcN_ys5J8FMdhTBAaN5V_YtAWpBH1kP527q_raw1wWdnIvLKQk9hsQJqdldZoKM6mZgyE5_lAWzLs1KN4xwD7Gbz3uQVoaIdIGGsW1iXhB6wJ7WeN9vD6kAJBiI9aHn_iJLmh-QPEWPdMntVipec4UXAACVXPX_QmOvFYxdVhSQp9tdmzpvAfVpQpsbrF29ro0olru0Aimv73wMp4UtIacGSu2T7rHfwkXJ05o9IDuUnjOC9oXMhxLvz_dBwjHeHt_B3BvBQ-XNSEQra0fD0MzJ3GBRqK1vUWRJQzaUmfZF5aE39az8qoRZBAYKFrAzqE8Y2IsEK6UhrJj4QuJ03l_skguhXuraLyH-IO6fnRqF5lZQgO81RIZKDvRlhNrcGJsM6yOotUXXTpVz9xjOtn1rMO1woO0up8kr16vlcRKp_TUh_VqDvV-AbY93ZYBUuvVUiLonGaOK7V3X7uqJGFsh0f27hy7CKYyjviPLo9eEs_oMsjh34cLEzDEPSZtgdqbv6_82ruVRA6S5wKWr6v3HluBVjJP7Q8iBJbLzFfl85ihIjj04hYZQmBUx0E0a646NVETdibYC7zcmdtGOUb045Nifb3A
IdentityServer Config :
public static class IdentityServerConfig
{
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("api1", "My API")
};
}
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile()
};
}
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "angular_spa",
ClientName = "Angular 4 Client",
AllowedGrantTypes = GrantTypes.Code,
RequirePkce = true,
RequireClientSecret = false,
AllowedScopes = new List<string> {"openid", "profile", "api1"},
RedirectUris = new List<string> {"http://localhost:4200/auth-callback", "http://localhost:4200/silent-refresh.html"},
PostLogoutRedirectUris = new List<string> {"http://localhost:4200/"},
AllowedCorsOrigins = new List<string> {"http://localhost:4200"},
AllowAccessTokensViaBrowser = true
}
};
}
}
Angular Configurations :
export function getClientSettings(): UserManagerSettings {
return {
authority: 'http://localhost:44380/',
client_id: 'angular_spa',
redirect_uri: 'http://localhost:4200/auth-callback',
post_logout_redirect_uri: 'http://localhost:4200/',
response_type: "code",
scope: "openid profile api1",
filterProtocolClaims: true,
loadUserInfo: true
};
}
Kindly let me know what could have gone wrong
Hi Scott,
first I want to say thank you for your sample. It works as demo but I am missing some real life ascpects it could consider ;-)
According to http://openid.net/specs/openid-connect-core-1_0.html you just have to define a redirect uri registered at the IdP thats it.
Well there are open questions looking at your sample:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> | Promise<boolean> {
if(this.authService.isLoggedIn()) {
return true;
}
this.authService.startAuthentication();
return false;
}
The authService.isLoggedIn check wether the user is !== null thus the user was not reloaded here yet by the completeAuthentication function the startAuthentication function will be called. This again triggers the auth_callback route and everything starts again... now it gets recursive...
As I said my app has only protected routes. And making a redirect after authorization to the auth_callback route always hits the AuthGuard first which wants to start the authentication again as the user is null.
Do you get my dilemma?
Maybe you have an idea :-)
Hi All,
We are facing the could not complete the authentication: Error: Unauthorized (401) in IE browser window 7 OS.
The IE Browser version is IE Edge.
could not complete authentication: Error: Unauthorized (401)
ERROR Error: Uncaught (in promise): TypeError: Unable to get property 'profile' of undefined or null reference
TypeError: Unable to get property 'profile' of undefined or null reference
How do I get a new Token from Token Endpoint after expiration of the token without going to the Authorization Endpoint and then redirect to Callback Endpoint?
(so that the user does not understand it)
Hi,
I found a problem with your code that fixed issue with my on refreshing the browser and losing the data which I struggled for weeks.
change this:
private user: User = null;
this this:
private user: User;
What I found is that this fire on initialization and when you refresh browser and it is injected as a provider it will reset the value. Ultimately thinking your are logged in on the back end, but not actually loggedin on the front end because you can't retrieve any user data.
Hi,
I took your code from the repo and updated UserManagerSettings....It works as it should. But when I try to add:
automaticSilentRenew: true,
silent_redirect_uri: 'http://localhost:4200/silent-refresh.html'
in UserManagerSettings as you have explained in your 'Silent Refresh - Refreshing Access Tokens when using the Implicit Flow' it tries to do silent refresh but then it fails and always getting 'oidc-client.min.js:1 SilentRenewService._tokenExpiring: Error from signinSilent: Frame window timed out' message on the console. I checked other post related to this but didn't find solution.
Thanks
Hi,
Thank you for tutorial, I am having issue with saving information of user data, so i can access it to other pages, able to access on callback url, but not anywhere else when information is in url. Can you help me out please.
https://github.com/premiumwd/a
how do i retrieve the file userinfo once authentication completes? This file is responsible for getting claims.
Hi Scott,
I actually work on a web project with Angular and I would add some Identity Server authentication on it.
I have somes questions related to redirection on redirect url after login.
Foremost, thank you for your example and your tutorial.
However I faced some troubles while putting it into practice.
I begin my process on my home page with this url :
http://localhost:4200/#/pages/dashboard
For the moment, I have no buttons to access the protected component. Also, I used this url to access protected component into my navigator :
http://localhost:4200/#/pages/protected
This url drove me well on identity server authentification page. However, after sign in, the returned url in navigator becomes :
http://localhost:4200/auth-callback#/pages/dashboard
Firstly, how can I avoid the insertion of "auth-callback" in the url ?
Secondly, I am not able to access to my protected page url
Indeed, when I tried to access it, it always redirect me on following url :
http://localhost:4200/auth-callback#/pages/dashboard
Instead of :
http://localhost:4200/auth-callback#/pages/protected
Did I miss something in my configuration ?
Config.cs file on Identity Server Side
new Client
{
ClientId = "spa",
ClientName = "SPA Client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris =
{
"http://localhost:4200/auth-callback",
},
PostLogoutRedirectUris = { "http://localhost:4200/" },
AllowedCorsOrigins = { "http://localhost:4200" },
AllowedScopes = {
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OpenId,
Utils.IdentityResourcesUtil.Roles,
"ibis_api"
}
},
auth.service.ts file on my angular web project :
import { Injectable } from '@angular/core';
import { UserManager, UserManagerSettings, User, WebStorageStateStore } from 'oidc-client';
@Injectable({
providedIn: 'root',
})
export class AuthService {
private manager = new UserManager(getClientSettings());
private user: User = null;
constructor() {
this.manager.getUser().then(user => {
this.user = user;
});
}
isLoggedIn(): boolean {
return this.user != null && !this.user.expired;
}
getClaims(): any {
return this.user.profile;
}
getAuthorizationHeaderValue(): string {
return `${this.user.token_type} ${this.user.access_token}`;
}
startAuthentication(): Promise<void> {
return this.manager.signinRedirect();
}
completeAuthentication(): Promise<void> {
return this.manager.signinRedirectCallback().then(user => {
this.user = user;
});
}
}
export function getClientSettings(): UserManagerSettings {
return {
authority: 'http://localhost:5000/',
client_id: 'spa',
redirect_uri: 'http://localhost:4200/auth-callback',
post_logout_redirect_uri: 'http://localhost:4200/',
response_type: 'id_token token',
scope: 'email profile openid',
filterProtocolClaims: true,
loadUserInfo: true,
userStore: new WebStorageStateStore({ store: window.localStorage }),
};
auth-callback.component.ts file
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../services/auth.service';
@Component({
selector: 'ngx-app-auth-callback',
templateUrl: './auth-callback.component.html',
styles: [],
})
export class AuthCallbackComponent implements OnInit {
constructor(private authService: AuthService) { }
ngOnInit() {
this.authService.completeAuthentication();
}
}
Thank you in advance for your answer.
hi, I implemented silent refresh operation in this project, but after each silent refresh operation, the user object in auth service
is not set to the new information, which causes the problem in isLoggedIn
and getAuthorizationHeaderValue
function.
How to set the user object from silent-refresh.html
file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.