Skip to content

Instantly share code, notes, and snippets.

View alx-andru's full-sized avatar
👨‍💻
code, deploy, repeat

Alex alx-andru

👨‍💻
code, deploy, repeat
View GitHub Profile
@alx-andru
alx-andru / auth.ts
Last active September 28, 2020 15:13
Code experiment to resolve "unknown method" due to proxy polyfill in IE11
import {
Injectable,
Inject,
Optional,
NgZone,
PLATFORM_ID,
} from "@angular/core";
import { Observable, of, from } from "rxjs";
import {
switchMap,

Keybase proof

I hereby claim:

  • I am alx-andru on github.
  • I am alx_andru (https://keybase.io/alx_andru) on keybase.
  • I have a public key ASDXHHo7C87MoRYcOFAGwBLzZZtmgi4GoNZutgjDM2JY8Ao

To claim this, I am signing this object:

NgOidcClientModule.forRoot({
oidc_config: {
authority:
'https://login.microsoftonline.com/TENANT_ID/v2.0',
client_id: 'CLIENT_ID',
redirect_uri: 'https://localhost:4200/callback.html',
response_type: 'id_token token',
scope: 'openid profile offline_access',
loadUserInfo: false,
post_logout_redirect_uri:
export function logout(reducer: ActionReducer<any>): ActionReducer<any> {
return function(state: any, action: any) {
// Reset state if user logs out
if (action.type === OidcActions.OidcActionTypes.OnUserSignedOut) {
return reducer(undefined, action);
}
return reducer(state, action);
};
}
@Effect()
loadUser$: Observable<Action> = this.actions$.pipe(
ofType(UserActionTypes.USER_GET_ME, OidcActions.OidcActionTypes.UserFound),
switchMap(() =>
this.userService.getMe().pipe(
first(),
map((user: User) => {
return new GetUserMeSuccess(user);
}),
catchError(error => {
...
export class OidcEffectsService {
constructor(private actions$: Actions, private router: Router) {}
@Effect({ dispatch: false })
onUserSignedOut$: Observable<Action> = this.actions$.pipe(
ofType(OidcActions.OidcActionTypes.OnUserSignedOut),
tap(args => {
this.router.navigate(['/home']);
})
NgOidcClientModule.forRoot({
oidc_config: {
authority: 'YOUR_DOMAIN', // e.g. https://dev-133788.oktapreview.com
client_id: 'YOUR_CLIENT_ID',
redirect_uri: 'http://localhost:4200/callback.html',
response_type: 'id_token token',
scope: 'openid profile offline_access',
post_logout_redirect_uri: 'http://localhost:4200/signout-callback.html',
silent_redirect_uri: 'http://localhost:4200/renew-callback.html',
automaticSilentRenew: true
NgOidcClientModule.forRoot({
oidc_config: {
authority: 'https://YOUR_DOMAIN.auth0.com', // e.g. https://ngOidcClient.auth0.com/'
client_id: 'YOUR_CLIENT_ID',
redirect_uri: 'http://localhost:4200/callback.html',
response_type: 'id_token token',
scope: 'openid profile offline_access api1',
post_logout_redirect_uri: 'http://localhost:4200/signout-callback.html',
silent_redirect_uri: 'http://localhost:4200/renew-callback.html',
automaticSilentRenew: true,
@alx-andru
alx-andru / home-component.ts
Last active November 4, 2018 01:38
Modified HomeComponent to test token interceptor
...
export class HomeComponent implements OnInit {
userInfo$: Observable<User>;
constructor(private http: HttpClient, private oidcFacade: OidcFacade) {}
ngOnInit() {}
checkUserInfo() {
const identityProviderUrl = this.oidcFacade.getOidcClient().settings.authority;