-
Notifications
You must be signed in to change notification settings - Fork 1
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
zitadel #15
base: main
Are you sure you want to change the base?
zitadel #15
Changes from 7 commits
0cb1e46
84a5d2e
c548ce5
07611fe
edf3efb
2640805
16c2825
e622ec9
3d9d5af
783e9ae
bc9c32c
223acc6
4c4eb27
0d20e1b
382ca64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; | ||
import { appConfig } from './app.config'; | ||
import { OAuthStorage } from 'angular-oauth2-oidc'; | ||
|
||
const browserConfig: ApplicationConfig = { | ||
providers: [ | ||
{ | ||
provide: OAuthStorage, | ||
useValue: localStorage, | ||
} | ||
] | ||
}; | ||
|
||
export const config = mergeApplicationConfig(appConfig, browserConfig); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,27 @@ import { provideClientHydration } from '@angular/platform-browser'; | |
import { provideHttpClient, withFetch } from '@angular/common/http'; | ||
import { ArrowDownNarrowWide, ArrowDownWideNarrow, BookText, Box, Check, ChevronDown, ChevronLeft, ChevronRight, Codesandbox, Cpu, Database, DollarSign, Facebook, Github, Home, Hotel, Linkedin, LucideAngularModule, MemoryStick, PcCase, Search, Server, SquareKanban, Twitter, User, Building2, Heater, CandlestickChart, MapPinned, Scale, Ellipsis, Menu, Leaf, ShoppingCart, ChevronUp, ExternalLink, Info } from 'lucide-angular'; | ||
import { MarkdownModule } from 'ngx-markdown'; | ||
import { AuthConfig, OAuthModule } from 'angular-oauth2-oidc'; | ||
import { provideCharts, withDefaultRegisterables } from 'ng2-charts'; | ||
|
||
const ZITADEL_CLIENT_ID = import.meta.env['NG_APP_ZITADEL_CLIENT_ID']; | ||
const ZITADEL_DOMAIN = import.meta.env['NG_APP_ZITADEL_DOMAIN']; | ||
const ZITADEL_USERINFO_ENDPOINT = import.meta.env['NG_APP_ZITADEL_USERINFO_ENDPOINT']; | ||
Palabola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const DOMAIN_BASE_URL = import.meta.env['NG_APP_DOMAIN_BASE_URL']; | ||
|
||
const authConfig: AuthConfig = { | ||
scope: 'openid profile email offline_access', | ||
responseType: 'code', | ||
oidc: true, | ||
clientId: ZITADEL_CLIENT_ID, | ||
issuer: ZITADEL_DOMAIN, | ||
redirectUri: `${DOMAIN_BASE_URL}auth/callback`, | ||
postLogoutRedirectUri: `${DOMAIN_BASE_URL}`, | ||
requireHttps: false, // required for running locally | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure |
||
tokenEndpoint: `${ZITADEL_DOMAIN}/oauth/v2/token`, | ||
userinfoEndpoint: ZITADEL_USERINFO_ENDPOINT, | ||
}; | ||
Comment on lines
+12
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the OAuth configuration settings in the |
||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideRouter(routes), | ||
|
@@ -55,6 +74,21 @@ export const appConfig: ApplicationConfig = { | |
}), | ||
), | ||
importProvidersFrom(MarkdownModule.forRoot()), | ||
importProvidersFrom( | ||
OAuthModule.forRoot({ | ||
resourceServer: { | ||
allowedUrls: [ | ||
`${ZITADEL_DOMAIN}/admin/v1`, | ||
`${ZITADEL_DOMAIN}/management/v1`, | ||
`${ZITADEL_DOMAIN}/auth/v1/`], | ||
sendAccessToken: true, | ||
}, | ||
}) | ||
), | ||
{ | ||
provide: AuthConfig, | ||
useValue: authConfig, | ||
} | ||
], | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="w-full"> | ||
<div class="content_section"> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.content_section { | ||
@apply bg-primary; | ||
@apply text-white; | ||
|
||
padding: 4rem 2rem; | ||
height: 100vh; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CallbackComponent } from './callback.component'; | ||
|
||
describe('CallbackComponent', () => { | ||
let component: CallbackComponent; | ||
let fixture: ComponentFixture<CallbackComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [CallbackComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(CallbackComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
Palabola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core'; | ||
import { AuthenticationService } from '../../services/authentication.service'; | ||
import { Router, RouterModule } from '@angular/router'; | ||
import { isPlatformBrowser } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'app-callback', | ||
standalone: true, | ||
imports: [RouterModule], | ||
templateUrl: './callback.component.html', | ||
styleUrl: './callback.component.scss' | ||
}) | ||
export class CallbackComponent implements OnInit{ | ||
|
||
constructor( | ||
@Inject(PLATFORM_ID) private platformId: object, | ||
private authService: AuthenticationService, | ||
private router: Router | ||
) { } | ||
|
||
ngOnInit() { | ||
|
||
if(isPlatformBrowser(this.platformId)) { | ||
this.authService.loginCodeFlow().then(() => { | ||
const url = sessionStorage.getItem('prelogin_url') || '/'; | ||
sessionStorage.removeItem('prelogin_url'); | ||
this.router.navigateByUrl(url); | ||
}); | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { CanActivateFn } from '@angular/router'; | ||
|
||
import { authGuard } from './auth.guard'; | ||
|
||
describe('authGuard', () => { | ||
const executeGuard: CanActivateFn = (...guardParameters) => | ||
TestBed.runInInjectionContext(() => authGuard(...guardParameters)); | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(executeGuard).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { CanActivateFn } from '@angular/router'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert imports to type-only imports to clarify their usage. - import { CanActivateFn } from '@angular/router';
- import { AuthenticationService } from '../services/authentication.service';
+ import type { CanActivateFn } from '@angular/router';
+ import type { AuthenticationService } from '../services/authentication.service';
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { AuthenticationService } from '../services/authentication.service'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { inject } from '@angular/core'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { map, take } from 'rxjs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const authGuard: CanActivateFn = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const authService = inject(AuthenticationService); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return authService.authedState.pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
take(1), // Otherwise the Observable doesn't complete! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
map((isAuthenticated) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isAuthenticated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
authService.authenticate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return authService.isLoggedIn(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider simplifying the guard logic by removing the unnecessary - } else {
- authService.authenticate();
- return authService.isLoggedIn();
- } Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the guard logic by removing the unnecessary - } else {
- authService.authenticate();
- return authService.isLoggedIn();
- } Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,14 +1,34 @@ | ||||||||||||||
import { Component } from '@angular/core'; | ||||||||||||||
import { RouterLink } from '@angular/router'; | ||||||||||||||
import { LucideAngularModule } from 'lucide-angular'; | ||||||||||||||
import { AuthenticationService } from '../../services/authentication.service'; | ||||||||||||||
import { CommonModule } from '@angular/common'; | ||||||||||||||
Comment on lines
3
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review the import usage as they are only used as types. Consider using TypeScript's - import { AuthenticationService } from '../../services/authentication.service';
- import { CommonModule } from '@angular/common';
+ import type { AuthenticationService } from '../../services/authentication.service';
+ import type { CommonModule } from '@angular/common'; Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
@Component({ | ||||||||||||||
selector: 'app-header', | ||||||||||||||
standalone: true, | ||||||||||||||
imports: [LucideAngularModule, RouterLink], | ||||||||||||||
imports: [LucideAngularModule, RouterLink, CommonModule], | ||||||||||||||
templateUrl: './header.component.html', | ||||||||||||||
styleUrl: './header.component.scss' | ||||||||||||||
styleUrl: './header.component.scss', | ||||||||||||||
// eslint-disable-next-line @angular-eslint/no-host-metadata-property | ||||||||||||||
host: {ngSkipHydration: 'true'}, | ||||||||||||||
}) | ||||||||||||||
export class HeaderComponent { | ||||||||||||||
|
||||||||||||||
constructor( | ||||||||||||||
private authService: AuthenticationService | ||||||||||||||
) { } | ||||||||||||||
|
||||||||||||||
isLoggedIn() { | ||||||||||||||
return this.authService.isLoggedIn(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
login() { | ||||||||||||||
this.authService.authenticate(); | ||||||||||||||
} | ||||||||||||||
Palabola marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
logout() { | ||||||||||||||
this.authService.signout(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="w-full bg-primary"> | ||
<div class="content pt-16 pb-16"> | ||
<app-breadcrumbs [segments]="breadcrumbs"></app-breadcrumbs> | ||
|
||
<div class="flex flex-col gap-4 my-8"> | ||
<h1 class="text-white font-bold text-3xl">Cloud Compute Resources listing</h1> | ||
<div class="text-white text-xl pr-16"> | ||
Explore, search and evaluate cloud compute resources and pricing in the table below. This comprehensive comparison includes diverse attributes like CPU count, detailed processor information, memory, GPU, storage, network speed and amount, available operating systems, and pricing models such as spot and on-demand. Use the sidebar for filtering the results, or enter your phrase in the “Search prompt” bar. | ||
</div> | ||
</div> | ||
|
||
<div class="flex gap-8"> | ||
<div class="filter_bar bg-primary"> | ||
<div class="filters overflow-hidden bg-secondary"> | ||
</div> | ||
</div> | ||
<div class=" list_holder flex flex-col gap-4 limited-full"> | ||
<div class="top_buttons w-full flex justify-end gap-6 items-center" > | ||
|
||
</div> | ||
<div> | ||
<div class="w-full overflow-x-auto relative" style="padding-left: 1px;"> | ||
|
||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> |
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.
Tip
Codebase Verification
The codebase includes checks for
isPlatformBrowser(this.platformId)
in bothsrc/app/app.component.ts
andsrc/app/pages/landingpage/landingpage.component.ts
. However, there is no clear indication of environment-specific configurations for analytics initialization.src/app/app.component.ts
initializes tracking inngAfterViewInit
if the platform is a browser.src/app/pages/landingpage/landingpage.component.ts
fetches articles if the platform is a browser.There is no explicit differentiation between production and other environments in the provided context.
src/app/app.component.ts
src/app/pages/landingpage/landingpage.component.ts
Analysis chain
The integration of
AnalyticsService
for tracking page views is implemented correctly. Ensure that the tracking is configured appropriately for different environments.Also applies to: 24-24, 38-38, 58-60
Scripts Executed
The following scripts were executed for the analysis:
Script:
Length of output: 106
Script:
Length of output: 302
Script:
Length of output: 974