Skip to content

Commit

Permalink
Pull request #167: Development
Browse files Browse the repository at this point in the history
Merge in ITB/gitb from development to master

* commit 'b54edefaad610691cd3086d4ec176fb9e71cad21':
  Hotfix: Corrected entrypoint to handle special characters
  Hotfix: External link navigation
  • Loading branch information
costas80 committed Oct 16, 2024
2 parents 79f1d7d + b54edef commit f340568
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 37 deletions.
58 changes: 38 additions & 20 deletions etc/docker/gitb-ui/gitb-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,48 @@ cat > /usr/local/gitb-ui/conf/overrides.conf << EOF
include "application"
EOF

if [[ -n "$DB_DEFAULT_PASSWORD_FILE" ]] ; then
echo "slick.dbs.default.db.password=$(cat $DB_DEFAULT_PASSWORD_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
echo "db.default.password=$(cat $DB_DEFAULT_PASSWORD_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$APPLICATION_SECRET_FILE" ]] ; then
echo "play.http.secret.key=$(cat $APPLICATION_SECRET_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$MASTER_PASSWORD_FILE" ]] ; then
echo "masterPassword=$(cat $MASTER_PASSWORD_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
if [[ -n "$DB_DEFAULT_PASSWORD_FILE" ]] ; then
echo -n 'slick.dbs.default.db.password="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $DB_DEFAULT_PASSWORD_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n 'db.default.password="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $DB_DEFAULT_PASSWORD_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$APPLICATION_SECRET_FILE" ]] ; then
echo -n 'play.http.secret.key="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $APPLICATION_SECRET_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$MASTER_PASSWORD_FILE" ]] ; then
echo -n 'masterPassword="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $MASTER_PASSWORD_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$AUTOMATION_API_MASTER_KEY_FILE" ]] ; then
echo "masterApiKey=$(cat $AUTOMATION_API_MASTER_KEY_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n 'masterApiKey="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $AUTOMATION_API_MASTER_KEY_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$HMAC_KEY_FILE" ]] ; then
echo "hmac.key=$(cat $HMAC_KEY_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$DATA_ARCHIVE_KEY_FILE" ]] ; then
echo "dataArchive.key=$(cat $DATA_ARCHIVE_KEY_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$PROXY_SERVER_AUTH_PASSWORD_FILE" ]] ; then
echo "proxy.auth.password=$(cat $PROXY_SERVER_AUTH_PASSWORD_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$EMAIL_SMTP_AUTH_PASSWORD_FILE" ]] ; then
echo "email.smtp.auth.password=$(cat $EMAIL_SMTP_AUTH_PASSWORD_FILE)" >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n 'hmac.key="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $HMAC_KEY_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$DATA_ARCHIVE_KEY_FILE" ]] ; then
echo -n 'dataArchive.key="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $DATA_ARCHIVE_KEY_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$PROXY_SERVER_AUTH_PASSWORD_FILE" ]] ; then
echo -n 'proxy.auth.password="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $PROXY_SERVER_AUTH_PASSWORD_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi
if [[ -n "$EMAIL_SMTP_AUTH_PASSWORD_FILE" ]] ; then
echo -n 'email.smtp.auth.password="""' >> /usr/local/gitb-ui/conf/overrides.conf;
echo -n $(cat $EMAIL_SMTP_AUTH_PASSWORD_FILE) >> /usr/local/gitb-ui/conf/overrides.conf;
echo '"""' >> /usr/local/gitb-ui/conf/overrides.conf;
fi

exec gitb -Dconfig.file=/usr/local/gitb-ui/conf/overrides.conf
2 changes: 1 addition & 1 deletion gitb-ui/app/models/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ object Constants {

// When ending in "-snapshot", this is considered a non-published release.
val VersionNumber = "1.24.0"
val VersionNumberPostfixForResources = ""
val VersionNumberPostfixForResources = "-b1"

}
9 changes: 5 additions & 4 deletions gitb-ui/ui/src/app/resolvers/admin-view-guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AdminViewGuard {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.userLoaded().pipe(
return this.userLoaded(state).pipe(
mergeMap(() => {
if (this.dataService.isCommunityAdmin || this.dataService.isSystemAdmin) {
return of(true)
Expand All @@ -36,11 +36,12 @@ export class AdminViewGuard {
)
}

private userLoaded(): Observable<any> {
if (this.dataService.user) {
private userLoaded(state: RouterStateSnapshot): Observable<any> {
if (this.dataService.user?.id) {
// The ID property of the user is set only after all information on the user had been loaded.
return of(true)
} else {
return this.profileResolver.resolveData()
return this.profileResolver.resolveData(state)
}
}

Expand Down
4 changes: 2 additions & 2 deletions gitb-ui/ui/src/app/resolvers/profile-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ProfileResolver {
private authService: AuthService,
) {}

resolveData(): Observable<void> {
resolveData(state: RouterStateSnapshot): Observable<void> {
let result: Observable<any>
const authenticated = this.authProviderService.isAuthenticated()
let configObservable: Observable<any>
Expand Down Expand Up @@ -123,7 +123,7 @@ export class ProfileResolver {
}

resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<void> {
return this.resolveData()
return this.resolveData(state)
}

}
10 changes: 5 additions & 5 deletions gitb-ui/ui/src/app/resolvers/route-authentication.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ export class RouteAuthenticationGuard {
if (state.url === '/login') {
this.dataService.applyRequestedRoute()
if (this.authProviderService.isAuthenticated()) {
return this.goToStartForUser(state.url)
return this.goToStartForUser(state)
} else {
return true
}
} else {
this.dataService.recordLocationDataOrRequestedRoute(state.url)
if (this.authProviderService.isAuthenticated()) {
return this.goToStartForUser(state.url)
return this.goToStartForUser(state)
} else {
return this.routingService.toLogin()
}
}
}

private goToStartForUser(currentUrl: string): Observable<boolean> {
private goToStartForUser(state: RouterStateSnapshot): Observable<boolean> {
let userId$: Observable<number>
if (this.dataService.user?.id) {
userId$ = of(this.dataService.user.id)
} else {
userId$ = this.profileResolver.resolveData().pipe(
userId$ = this.profileResolver.resolveData(state).pipe(
mergeMap(() => {
return of(this.dataService.user!.id!)
})
Expand All @@ -54,7 +54,7 @@ export class RouteAuthenticationGuard {
const location = this.dataService.retrieveLocationData(userId)
if (location == undefined) {
return this.routingService.toHome()
} else if (location == currentUrl) {
} else if (location == state.url) {
return of(true)
} else {
return this.routingService.toURL(location)
Expand Down
11 changes: 6 additions & 5 deletions gitb-ui/ui/src/app/resolvers/system-admin-view-guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class SystemAdminViewGuard {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.userLoaded().pipe(
return this.userLoaded(state).pipe(
mergeMap(() => {
if (this.dataService.isCommunityAdmin || this.dataService.isSystemAdmin) {
if (this.dataService.isSystemAdmin) {
return of(true)
} else {
return this.errorService.showUnauthorisedAccessError().pipe(
Expand All @@ -36,11 +36,12 @@ export class SystemAdminViewGuard {
)
}

private userLoaded(): Observable<any> {
if (this.dataService.user) {
private userLoaded(state: RouterStateSnapshot): Observable<any> {
// The ID property of the user is set only after all information on the user had been loaded.
if (this.dataService.user?.id) {
return of(true)
} else {
return this.profileResolver.resolveData()
return this.profileResolver.resolveData(state)
}
}

Expand Down

0 comments on commit f340568

Please sign in to comment.