-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add withAppInitializerAuthCheck
as a feature for provideAuth
#2006
Merged
FabianGosebrink
merged 3 commits into
damienbod:main
from
kyubisation:feat-app-initializer-auth-check
Oct 9, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
provideHttpClient, | ||
withInterceptors, | ||
withInterceptorsFromDi, | ||
} from '@angular/common/http'; | ||
import { ApplicationConfig } from '@angular/core'; | ||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; | ||
import { provideRouter } from '@angular/router'; | ||
import { | ||
authInterceptor, | ||
LogLevel, | ||
provideAuth, | ||
withAppInitializerAuthCheck, | ||
} from 'angular-auth-oidc-client'; | ||
|
||
import { routes } from './app.routes'; | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideRouter(routes), | ||
provideAnimationsAsync(), | ||
provideAuth( | ||
{ | ||
config: { | ||
authority: | ||
'https://login.microsoftonline.com/7ff95b15-dc21-4ba6-bc92-824856578fc1/v2.0', | ||
authWellknownEndpointUrl: | ||
'https://login.microsoftonline.com/common/v2.0', | ||
redirectUrl: window.location.origin, | ||
clientId: 'e38ea64a-2962-4cde-bfe7-dd2822fdab32', | ||
scope: | ||
'openid profile offline_access email api://e38ea64a-2962-4cde-bfe7-dd2822fdab32/access_as_user', | ||
responseType: 'code', | ||
silentRenew: true, | ||
maxIdTokenIatOffsetAllowedInSeconds: 600, | ||
issValidationOff: true, | ||
autoUserInfo: false, | ||
// silentRenewUrl: window.location.origin + '/silent-renew.html', | ||
useRefreshToken: true, | ||
logLevel: LogLevel.Debug, | ||
customParamsAuthRequest: { | ||
prompt: 'select_account', // login, consent | ||
}, | ||
}, | ||
}, | ||
withAppInitializerAuthCheck() | ||
), | ||
provideHttpClient( | ||
withInterceptorsFromDi(), | ||
withInterceptors([authInterceptor()]) | ||
), | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { AutoLoginAllRoutesGuard } from 'angular-auth-oidc-client'; | ||
import { Routes } from '@angular/router'; | ||
import { autoLoginPartialRoutesGuard } from 'angular-auth-oidc-client'; | ||
import { ForbiddenComponent } from './forbidden/forbidden.component'; | ||
import { HomeComponent } from './home/home.component'; | ||
import { ProtectedComponent } from './protected/protected.component'; | ||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component'; | ||
|
||
const appRoutes: Routes = [ | ||
export const routes: Routes = [ | ||
{ path: '', pathMatch: 'full', redirectTo: 'home' }, | ||
{ | ||
path: 'home', | ||
component: HomeComponent, | ||
canActivate: [AutoLoginAllRoutesGuard], | ||
canActivate: [autoLoginPartialRoutesGuard], | ||
}, | ||
{ | ||
path: 'forbidden', | ||
component: ForbiddenComponent, | ||
canActivate: [AutoLoginAllRoutesGuard], | ||
canActivate: [autoLoginPartialRoutesGuard], | ||
}, | ||
{ | ||
path: 'protected', | ||
component: ProtectedComponent, | ||
canActivate: [AutoLoginAllRoutesGuard], | ||
canActivate: [autoLoginPartialRoutesGuard], | ||
}, | ||
{ path: 'unauthorized', component: UnauthorizedComponent }, | ||
]; | ||
|
||
export const routing = RouterModule.forRoot(appRoutes); |
32 changes: 0 additions & 32 deletions
32
projects/sample-code-flow-azuread/src/app/auth-config.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
projects/sample-code-flow-azuread/src/app/home/home.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/sample-code-flow-azuread/src/app/nav-menu/nav-menu.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also refer to the
checkAuth
API, this keeps the documentation in one place.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain this in more detail? I'm not sure I fully understand what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs already provide information and an example for
checkAuth
andcheckAuthMultiple
.This means we can (in my opinion) just refer to the documentation, instead of including it here.
This prevents duplicates and makes it easier to change/update the docs later.
We can remove this section and update the text above the example, something as:
As a result we don't repeat ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that, but @FabianGosebrink requested to
add docs to have the "old" and "new" way side by side or underneath, so that we can link to it
.I'm fine with either. Should I adapt, as suggested by @timdeschryver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nevermind my comment then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy, I just wanted it to make it as easy as possible for the users to use. I am fine with both :)