Coder Social home page Coder Social logo

source-inc / ng-oidc-client Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 15.0 6.79 MB

A package for managing OpenID-Connect authentication in Angular apps, wrapping oidc-client-js

License: MIT License

JavaScript 4.33% TypeScript 84.04% HTML 9.85% CSS 1.78%
ng-oidc-client oidc oidc-client-js

ng-oidc-client's People

Contributors

alx-andru avatar david-on-github avatar jfensch avatar lejdholt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-oidc-client's Issues

Can't resolve all parameters for OidcFacade

running ng build --prod results in following error message:

ERROR in : Can't resolve all parameters for OidcFacade in .../ClientApp/node_modules/ng-oidc-client/ng-oidc-client.d.ts: (?).

Deep import into @ngrx/store causes ngcc warning

Describe the bug
https://github.com/sourcenetwork/ng-oidc-client/blob/b4f0e7d247cbf47e0372798857e216781360008c/projects/ng-oidc-client/src/lib/effects/oidc.effect.ts#L3

Warning: Entry point 'ng-oidc-client' contains deep imports into 'node_modules/@ngrx/store/src/models'. This is probably not a problem, but may cause the compilation of entry points to be out of order.

To Reproduce
Steps to reproduce the behavior:

  1. npm install ng-oidc-client
  2. Build application
  3. ngcc returns warning

Expected behavior
This Action should be imported from '@ngrx/store' and ngcc doesn't return a Warning

Additional context

> ng "version"

Angular CLI: 9.0.5
Node: 13.8.0
OS: darwin x64

Angular: 9.0.5
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.900.5
@angular-devkit/build-angular              0.900.5
@angular-devkit/build-optimizer            0.900.5
@angular-devkit/build-webpack              0.900.5
@angular-devkit/core                       9.0.5
@angular-devkit/schematics                 9.0.5
@angular/cdk                               9.1.1
@angular/material                          9.1.1
@ngtools/webpack                           9.0.5
@schematics/angular                        9.0.5 (cli-only)
@schematics/update                         0.900.5
rxjs                                       6.5.4
typescript                                 3.7.5
webpack                                    4.41.2

Angular 9 - authenticated user not loaded

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Implement Router guard. In CanActivate()

return this.oidcFacade.waitForAuthenticationLoaded().pipe(
switchMap(() => {
return this.oidcFacade.identity$.pipe(

  1. Start application from url with implicit authentication via guard
  2. No user loaded

Expected behavior

This was fine in Angular 8, but no longer working in Angular 9?

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version 80.0.3987.132

Additional context

Does the product support Angular 9?

Returned null User object after login

I am using oidc-client and ng-oidc-client combination for angular client and Identity server 4 as server.
Login was successful but this.oidcFacade.identity$.pipe is always returning null User object after login.

Strange import from @angular/core

Hello,
I've encountered a problem when using this library through npm.

The file node_modules\ng-oidc-client\fesm5\ng-oidc-client.js contains the following import:

import { InjectionToken, Injectable, Inject, PLATFORM_ID, ɵɵdefineInjectable, ɵɵinject, NgModule } from '@angular/core';

It throws several warnings like the one below when building:

WARNING in C:/Code/ocCore/Clients/angular/node_modules/ng-oidc-client/fesm5/ng-oidc-client.js 620:53-71
"export 'ɵɵdefineInjectable' was not found in '@angular/core'

This char is wrong: ɵɵ. If you remove it, everything works as expected.

Why does the file contain that char? Wrong code published to npm?

packages:

"@angular/core": "^7.2.15",
"ng-oidc-client": "^1.0.6",
"oidc-client": "^1.9.1",

Endless Page Loading (lazy loading module)

Does not work with lazy loading modules (ngrx)

I used => this.oidcFacade.getOidcUser(); in OidcGuardService

export class OidcGuardService implements CanActivate {
  constructor(private router: Router, private oidcFacade: OidcFacade) { }

public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
    this.oidcFacade.getOidcUser();
    return this.oidcFacade.waitForAuthenticationLoaded().pipe(
      switchMap(loading => {
        return this.oidcFacade.identity$.pipe(
          first(),
          switchMap(user => {
            if (user && !user.expired) {
              return of(true);
            } else {
              this.router.navigate(['/home']);
              return of(false);
            }
          })
        );
      })
    );
  }
}

My routing module:

 {
    path: 'employee',
    loadChildren: () => import('@employee').then(m => m.EmployeeModule),
    canActivate: [OidcGuardService],
    runGuardsAndResolvers: 'always'
  }

I have on the village filters, sorting, pagination which by change causes action load data.
When pressed, endless loading occurs. The action works, but does not cause the next action

if I add it => this.oidcFacade.getOidcUser(), everything will work.

first load
image

second load (not work)
image

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error
    Expected behavior
    A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (if required for specific bug, please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

ResponseValidator._processSigninParams: Expecting code in response

Describe the bug
ResponseValidator._processSigninParams: Expecting code in response

i get problem in function of signinRedirectCallback that function throws Expecting code in response like error.. below is my configuration for OIDC in app.module.ts file

NgOidcClientModule.forRoot({
oidc_config: {
authority:
'http://172.16.23.104:4444',
client_id: 'js',
redirect_uri: 'http://localhost:4200/callback.html',
response_type: 'code',
scope: 'openid profile positions',
post_logout_redirect_uri:
'http://localhost:4200/signout-callback.html',
silent_redirect_uri: 'http://localhost:4200/renew-callback.html',
acr_values: 'tenant:EDF',
userStore: () => new WebStorageStateStore({store: localStorage}),
}
}),
and in login i simply call:- this.oidcFacade.signinRedirect();

and in callback.html file

<title>Callback</title> <script src="oidc-client.min.js" type="application/javascript"></script> <script> var Oidc = window.Oidc;
var config = {
  userStore: new Oidc.WebStorageStateStore({ store: window.localStorage })
}

if ((Oidc && Oidc.Log && Oidc.Log.logger)) {
Oidc.Log.logger = console;
}
var isPopupCallback = JSON.parse(window.localStorage.getItem('ngoidc:isPopupCallback'));
if (isPopupCallback) {
new Oidc.UserManager(config).signinPopupCallback();
} else {
new Oidc.UserManager(config).signinRedirectCallback().then(t => {
window.location = 'http://localhost:4200';
}).catch((e) => {
console.log(e);
});
}
</script>

Desktop (please complete the following information):

  • OS: ubuntu
  • Browser chrome

User Manager State is not passed in after logging

When using signingRedirect and passing in some state, the state is not set in the callback.

For example:
Callling oidcFacade.signinRedirect({ state: { returnUrl: window.location.href } }); and then trying to read the state in the callback from a HTML template for example:

  var config = {
    userStore: new Oidc.WebStorageStateStore({ store: window.localStorage }),
  };
  var mgr = new Oidc.UserManager(config);

mgr.signinRedirectCallback().then(
      function (user) {
            console.log(user);
       });

The user doesn't have the state that was passed in to signinRedirect, it is set to undefined. I have tried with response_mode query and also to set data: {} with the signinRedirect.

How to resend failed requests from httpInterceptor upon renewing token asynchronously

Hi, your help is greatly appreciated.

I am struck in finding a way to resend failed requests (401 unauthorized) captured while renewing token (silent refresh) through httpInterceptor.

I have httpInteceptor in place to attach bearer token to all outgoing web requests. When the token is expired, I get 401 unauthorized response from web server. I am catching these unauthorized request/responses and requesting for renewing token through silentSignin method from ng-oidc-client.

Silent renewal is happening through asynchronous call. I am not sure on how to resend failed requests with the renewed token. Any help on this is highly valuable for me. I tried re sending failed requests through setTimeOut, unfortunately requests are not getting captured under network tab.

User Found action violates strictActionSerializability NgRx 8 runtime check

Describe the bug

The OidcUser payload violates the new strictActionSerializability check in NgRx 8

export class UserFound implements Action {
  readonly type = OidcActionTypes.UserFound;

  constructor(public payload: OidcUser) {}
}

To Reproduce
Steps to reproduce the behavior:

  1. Update to NgRx 8
  2. Enable runtime checks
@NgModule({
  imports: [
    StoreModule.forRoot(reducers, {
      runtimeChecks: {
        strictStateImmutability: true,
        strictActionImmutability: true,
        strictStateSerializability: true,
        strictActionSerializability: true,
      },
    }),
  ],
})
  1. Login and call this.oidcFacade.getOidcUser();
  2. Console log shows error
    core.js:5847 ERROR Error: Detected unserializable action at "payload"

Expected behavior
[Oidc] User found action should complete without runtime error

Desktop (please complete the following information):

  • Windows 10
  • Browser chrome
  • Version 74

Load configuration at run-time as opposed to build-time

Is your feature request related to a problem? Please describe.

We are currently loading our configuration from a local asset. When deploying the application we can change the configuration before building and deploying within our CI pipeline. However, the build for our staging and production servers needs to be identical, so the configuration needs loading at run-time.

Describe the solution you'd like

Modify the library to support the loading of the configuration at run-time.

Describe alternatives you've considered

Loading the configuration from an external service, then using the Angular APP_INITIALIZER to inhibit the initialisation process until loaded. There have been problems with this approach, so currently isn't working.

Additional context

Looks as if the ng8 branch is supporting this feature? Will this be released and if so when?

Requests get refired after token refresh

Describe the bug
When the token gets refreshed all previous requests are fired again.
The request is a normal HTTP call, nothing fancy.

Expected behavior
The token call is the only call that's made

Screenshots
As you see, a few requests get refired and get cancelled.
image

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: All
  • Version: current version version of package, Angular 9

This bug could also come from the OIDC-Client package but i'm not sure.

Popup authentication is working but redirect one is failing

Describe the bug

First, thank you for amazing library. I have cloned the library locally, replaced oidc_config with my server details. Everything is good. I even checked the code with dummy server online i.e. https://demo.identityserver.io. It is working fine for Popup flow but it is giving error/failing during redirect flow.

To Reproduce
Steps to reproduce the behavior:

  1. Just clone/download the ng-oidc-client code and run with your own configuration.
  2. Run the application on localhost. If you click on the Redirect button, it should redirect to the authentication server.
  3. The user sees the blank screen with localhost callback in the URL but somehow fails to return to the home screen. Please see the attached images:

Consoler error

Expected behavior
The application should redirect to localhost after authentication without error like it is working for a popup.

Screenshots

Screenshot OIDC

Desktop (please complete the following information):
Any

Additional context
What could be the issue? Does it require some fix from the code side? Please help.

Loading config on APP_INITIALIZER

Sometimes the oidc configuration is not know until runtime. Redirect_uri, authority, may vary depending on the environment.

I would like the Config parameter on the forRoot to be optional and have a method to load configuration on the APP_INITIALIZER.

Update dependencies to reflect Angular 8.x

When updating to Angular 8 I get:

Package "ng-oidc-client" has an incompatible peer dependency to "@angular/common" (requires "^6.0.0-rc.0 || ^6.0.0" (extended), would install "8.2.2").

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.