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

CRISTAL-381: Make the github backend supported #687

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/src/api/WikiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export interface WikiConfig {
* @since 0.11
*/
realtimeURL?: string;
/**
* Authentication server base URL.
* @since 0.15
*/
authenticationBaseURL?: string;
homePage: string;
storage: Storage;
serverRendering: boolean;
Expand Down
10 changes: 9 additions & 1 deletion api/src/components/defaultWikiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export class DefaultWikiConfig implements WikiConfig {
* @since 0.11
*/
public realtimeURL?: string;

/**
* Authentication server base URL.
* @since 0.15
*/
authenticationBaseURL?: string;
// @ts-expect-error homePage is temporarily undefined during class
// initialization
public homePage: string;
Expand Down Expand Up @@ -77,12 +83,13 @@ export class DefaultWikiConfig implements WikiConfig {
serverRendering: boolean,
designSystem: string,
offline: boolean,
optional?: { realtimeURL?: string },
optional?: { realtimeURL?: string; authenticationBaseURL?: string },
): void {
this.name = name;
this.baseURL = baseURL;
this.baseRestURL = baseRestURL;
this.realtimeURL = optional?.realtimeURL;
this.authenticationBaseURL = optional?.authenticationBaseURL;
this.homePage = homePage;
this.serverRendering = serverRendering;
this.designSystem = designSystem;
Expand All @@ -96,6 +103,7 @@ export class DefaultWikiConfig implements WikiConfig {
this.baseURL = configObject.baseURL;
this.baseRestURL = configObject.baseRestURL;
this.realtimeURL = configObject.realtimeURL;
this.authenticationBaseURL = configObject.authenticationBaseURL;
this.homePage = configObject.homePage;
this.serverRendering = configObject.serverRendering;
this.offline = configObject.offline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import type { UserDetails } from "./userDetails";
*/
interface AuthenticationManager {
/**
* Starts the authentication process.
* Starts the authentication process.
* @since 0.15
*/
start(): void;
start(): Promise<void>;

/**
* Handle the callback.
Expand Down
51 changes: 51 additions & 0 deletions core/authentication/authentication-github-state/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@xwiki/cristal-authentication-github-state",
"version": "0.14.0",
"license": "LGPL 2.1",
"author": "XWiki Org Community <contact@xwiki.org>",
"homepage": "https://cristal.xwiki.org/",
"repository": {
"type": "git",
"directory": "/core/authentication/authentication-github-state",
"url": "https://github.com/xwiki-contrib/cristal/"
},
"bugs": {
"url": "https://jira.xwiki.org/projects/CRISTAL/"
},
"type": "module",
"exports": {
".": "./src/index.ts"
},
"main": "./src/index.ts",
"scripts": {
"build": "tsc --project tsconfig.json && vite build",
"clean": "rimraf dist",
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
"test": "vitest --run"
},
"dependencies": {
"inversify": "6.2.2",
"vue": "3.5.13"
},
"peerDependencies": {
"reflect-metadata": "0.2.2"
},
"devDependencies": {
"@types/js-cookie": "3.0.6",
"@xwiki/cristal-dev-config": "workspace:*",
"reflect-metadata": "0.2.2",
"typescript": "5.7.3",
"vite": "6.0.11"
},
"publishConfig": {
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.es.js",
"types": "./dist/index.d.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { injectable } from "inversify";
import { ref } from "vue";
import type { Ref } from "vue";

/**
* Authentication State for the GitHub backend.
*
* @since 0.15
*/
@injectable()
export class GitHubAuthenticationState {
readonly modalOpened: Ref<boolean> = ref(false);
}
23 changes: 23 additions & 0 deletions core/authentication/authentication-github-state/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { GitHubAuthenticationState } from "./GitHubAuthenticationState";

export { GitHubAuthenticationState };
16 changes: 16 additions & 0 deletions core/authentication/authentication-github-state/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"resolveJsonModule": true
},
"extends": "../../../tsconfig.json",
"include": [
"./src/index.ts",
"./src/**/*"
],
"exclude": [
"**/*.spec.ts",
"**/*.test.ts"
]
}
4 changes: 4 additions & 0 deletions core/authentication/authentication-github-state/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": ["../../../tsdoc.json"]
}
23 changes: 23 additions & 0 deletions core/authentication/authentication-github-state/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { generateConfig } from "../../../vite.config";

export default generateConfig(import.meta.url);
25 changes: 25 additions & 0 deletions core/authentication/authentication-github-state/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import localConfig from "./vite.config";
import { mergeConfig } from "vitest/config";
import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";

export default mergeConfig(defaultConfig, localConfig);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"authentication.github.modal.title": "GitHub Login",
"authentication.github.modal.step1": "Step 1: Copy the following code",
"authentication.github.modal.step2": "Step 2: Click {link}, paste the code and authorize the application.",
"authentication.github.modal.step2.link": "here",
"authentication.github.modal.timeLeft": "Time left: {expiration}.",
"authentication.github.modal.userCode.label": "User Code"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"authentication.github.modal.title": "Connexion à GitHub",
"authentication.github.modal.step1": "Étape 1 : Copier le code suivant",
"authentication.github.modal.step2": "Étape 2 : Cliquer {link}, coller le code et autoriser l'application.",
"authentication.github.modal.step2.link": "ici",
"authentication.github.modal.timeLeft": "Temps restant : {expiration}.",
"authentication.github.modal.userCode.label": "Code utilisateur"
}
60 changes: 60 additions & 0 deletions core/authentication/authentication-github-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@xwiki/cristal-authentication-github-ui",
"version": "0.14.0",
"license": "LGPL 2.1",
"author": "XWiki Org Community <contact@xwiki.org>",
"homepage": "https://cristal.xwiki.org/",
"repository": {
"type": "git",
"directory": "/core/authentication/authentication-github-ui",
"url": "https://github.com/xwiki-contrib/cristal/"
},
"bugs": {
"url": "https://jira.xwiki.org/projects/CRISTAL/"
},
"type": "module",
"exports": {
".": "./src/index.ts"
},
"main": "./src/index.ts",
"scripts": {
"build": "vue-tsc --project tsconfig.json && vite build",
"clean": "rimraf dist",
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
"test": "vitest --run"
},
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-authentication-api": "workspace:*",
"@xwiki/cristal-authentication-github-state": "workspace:*",
"@xwiki/cristal-browser-api": "workspace:*",
"@xwiki/cristal-icons": "workspace:*",
"@xwiki/cristal-uiextension-api": "workspace:*",
"@xwiki/cristal-uiextension-default": "workspace:*",
"inversify": "6.2.2",
"vue": "3.5.13",
"vue-i18n": "11.1.0"
},
"devDependencies": {
"@vue/test-utils": "2.4.6",
"@xwiki/cristal-dev-config": "workspace:*",
"@xwiki/cristal-dev-test-utils": "workspace:*",
"@xwiki/cristal-dsapi": "workspace:*",
"reflect-metadata": "0.2.2",
"typescript": "5.7.3",
"vite": "6.1.0",
"vitest": "3.0.5",
"vue-tsc": "2.2.0"
},
"publishConfig": {
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.es.js",
"types": "./dist/index.d.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { inject, injectable } from "inversify";
import type {
AuthenticationManager,
AuthenticationManagerProvider,
} from "@xwiki/cristal-authentication-api";
import type { UIExtension } from "@xwiki/cristal-uiextension-api";
import type { Component } from "vue";

/**
* Login {@link UIExtension} for the GitHub backend.
*
* @since 0.15
*/
@injectable()
export class GitHubLoginMenuUIExtension implements UIExtension {
id = "sidebar.actions.githubLoginMenu";
uixpName = "sidebar.actions";
order = 2100;
parameters = {};

constructor(
@inject<AuthenticationManagerProvider>("AuthenticationManagerProvider")
private authenticationManager: AuthenticationManagerProvider,
) {}

async component(): Promise<Component> {
return (await import("./vue/GitHubLoginMenu.vue")).default;
}

async enabled(): Promise<boolean> {
const authenticationManager: AuthenticationManager =
this.authenticationManager.get()!;
const authenticated: boolean =
await authenticationManager?.isAuthenticated();
return !authenticated;
}
}
Loading
Loading