-
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 all 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ import { register } from 'swiper/element/bundle'; | |
import { HeaderComponent } from './layout/header/header.component'; | ||
import { FooterComponent } from './layout/footer/footer.component'; | ||
import { AnalyticsService } from './services/analytics.service'; | ||
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. Tip Codebase Verification The codebase includes checks for
There is no explicit differentiation between production and other environments in the provided context.
Analysis chainThe integration of Also applies to: 24-24, 38-38, 58-60 Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that the analytics initialization is configured for production environments.
# Test: Search for environment-specific configurations in the codebase. Expect: Configurations that differentiate between production and other environments.
rg --type typescript $'if \(isPlatformBrowser\(this.platformId\)\) \{'
Length of output: 106 Script: #!/bin/bash
# Description: Verify that the analytics initialization is configured for production environments.
# Test: Search for environment-specific configurations in the codebase. Expect: Configurations that differentiate between production and other environments.
rg --type ts 'if \(isPlatformBrowser\(this.platformId\)\) \{'
Length of output: 302 Script: #!/bin/bash
# Description: Review the relevant lines in the identified files to check for environment-specific configurations.
# Display the relevant lines in `src/app/app.component.ts`
rg --type ts --context 5 'if \(isPlatformBrowser\(this.platformId\)\) \{' src/app/app.component.ts
# Display the relevant lines in `src/app/pages/landingpage/landingpage.component.ts`
rg --type ts --context 5 'if \(isPlatformBrowser\(this.platformId\)\) \{' src/app/pages/landingpage/landingpage.component.ts
Length of output: 974 |
||
import { AuthenticationService } from './services/authentication.service'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
|
@@ -20,6 +21,7 @@ export class AppComponent implements OnInit, AfterViewInit { | |
|
||
constructor(@Inject(PLATFORM_ID) private platformId: object, | ||
@Inject(DOCUMENT) private document: Document, | ||
private auth: AuthenticationService, | ||
private router: Router, | ||
private analytics: AnalyticsService, | ||
private metaTagService: Meta) { | ||
|
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 |
---|---|---|
|
@@ -4,10 +4,29 @@ import { provideRouter } from '@angular/router'; | |
import { routes } from './app.routes'; | ||
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 { 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, Settings, Star, Trash2 } 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), | ||
|
@@ -51,10 +70,28 @@ export const appConfig: ApplicationConfig = { | |
Leaf, | ||
ShoppingCart, | ||
ExternalLink, | ||
Info | ||
Info, | ||
Settings, | ||
Star, | ||
Trash2 | ||
}), | ||
), | ||
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 = (route) => { | ||||||
|
||||||
const authService = inject(AuthenticationService); | ||||||
|
||||||
return authService.authedState.pipe( | ||||||
take(1), | ||||||
map((isAuthenticated) => { | ||||||
if (isAuthenticated) { | ||||||
return true | ||||||
} else { | ||||||
authService.authenticate('/' + route.url.join('/')); | ||||||
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. Use template literals for path concatenation. - authService.authenticate('/' + route.url.join('/'));
+ authService.authenticate(`/${route.url.join('/')}`); Committable suggestion
Suggested change
|
||||||
return authService.isLoggedIn(); | ||||||
} | ||||||
}) | ||||||
); | ||||||
|
||||||
}; |
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(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
} |
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.
Avoid using bare URLs in markdown files.
Also applies to: 34-34, 35-35
Committable suggestion