Skip to content
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

[Editor]: Allow logging out #1039

Merged
merged 11 commits into from
Nov 25, 2024
5 changes: 5 additions & 0 deletions apps/metadata-editor/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { DashboardPageComponent } from './dashboard/dashboard-page.component'
import { EditorRouterService } from './router.service'
import {
LOGIN_URL,
LOGOUT_URL,
provideGn4,
provideRepositoryUrl,
} from '@geonetwork-ui/api/repository'
Expand Down Expand Up @@ -70,6 +71,10 @@ import { FeatureEditorModule } from '@geonetwork-ui/feature/editor'
provide: LOGIN_URL,
useFactory: () => getGlobalConfig().LOGIN_URL,
},
{
provide: LOGOUT_URL,
useFactory: () => getGlobalConfig().LOGOUT_URL,
},
],
bootstrap: [AppComponent],
})
Expand Down
1 change: 1 addition & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ proxy_path = ""
# - ${lang2}, ${lang3}: indicates if and where the current language should be part of the login URL in language 2 or 3 letter code
# Example to use the georchestra login page:
# login_url = "/cas/login?service=${current_url}"
# logout_url = "/geonetwork/signout?redirectUrl=\${current_url}"
# This optional URL should point to the static html page wc-embedder.html which allows to display a web component (like chart and table) via a permalink.
# URLs can be indicated from the root of the same server starting with a "/" or as an external URL. Be conscious of potential CORS issues when using an external URL.
# The default location in the dockerized datahub app for example is "/datahub/wc-embedder.html".
Expand Down
14 changes: 11 additions & 3 deletions libs/api/repository/src/lib/gn4/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import { TranslateService } from '@ngx-translate/core'
export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?redirect=\${current_url}`
export const LOGIN_URL = new InjectionToken<string>('loginUrl')

export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout`
export const LOGOUT_URL = new InjectionToken<string>('loginUrl')
cmoinier marked this conversation as resolved.
Show resolved Hide resolved

@Injectable({
providedIn: 'root',
})
export class AuthService {
baseLoginUrl = this.baseLoginUrlToken || DEFAULT_GN4_LOGIN_URL
baseLogoutUrl = this.baseLogoutUrlToken || DEFAULT_GN4_LOGOUT_URL
get loginUrl() {
let baseUrl = this.baseLoginUrl
const locationHasQueryParams = !!window.location.search
Expand All @@ -25,10 +29,14 @@ export class AuthService {
LANG_2_TO_3_MAPPER[this.translateService.currentLang]
)
}

get logoutUrl() {
return this.baseLogoutUrl
}

constructor(
@Optional()
@Inject(LOGIN_URL)
private baseLoginUrlToken: string,
@Optional() @Inject(LOGIN_URL) private baseLoginUrlToken: string,
@Optional() @Inject(LOGOUT_URL) private baseLogoutUrlToken: string,
private translateService: TranslateService
) {}
}
2 changes: 2 additions & 0 deletions libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function loadAppConfig() {
'proxy_path',
'metadata_language',
'login_url',
'logout_url',
'web_component_embedder_url',
'languages',
'contact_email',
Expand All @@ -124,6 +125,7 @@ export function loadAppConfig() {
).toLowerCase()
: undefined,
LOGIN_URL: parsedGlobalSection.login_url,
LOGOUT_URL: parsedGlobalSection.logout_url,
WEB_COMPONENT_EMBEDDER_URL:
parsedGlobalSection.web_component_embedder_url,
LANGUAGES: parsedGlobalSection.languages,
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ geonetwork4_api_url = "/geonetwork/srv/api"
proxy_path = "/proxy/?url="
metadata_language = "fre"
login_url = "/cas/login?service="
logout_url = "/geonetwork/signout?redirectUrl="
web_component_embedder_url = "/datahub/wc-embedder.html"

[map]
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface GlobalConfig {
PROXY_PATH?: string
METADATA_LANGUAGE?: string
LOGIN_URL?: string
LOGOUT_URL?: string
WEB_COMPONENT_EMBEDDER_URL?: string
LANGUAGES?: string[]
CONTACT_EMAIL?: string
Expand Down