From 554445dc348ceee8efdbaf6683c8cb35a9b4db01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 23 Jun 2017 11:10:32 +0200 Subject: [PATCH] Add support for the Kinto Account plugin. Fixes #436 --- src/components/AuthForm.js | 34 +++++++++++++++++++++++++++++++++- src/reducers/settings.js | 2 +- src/types.js | 24 ++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/components/AuthForm.js b/src/components/AuthForm.js index 41654a90f..3ad007ed3 100644 --- a/src/components/AuthForm.js +++ b/src/components/AuthForm.js @@ -88,7 +88,7 @@ const baseAuthSchema = { authType: { type: "string", title: "Authentication method", - enum: ["basicauth", "fxa", "ldap"], + enum: ["basicauth", "account", "fxa", "ldap"], }, }, }; @@ -103,6 +103,36 @@ const baseUISchema = { }; const authSchemas = { + account: { + schema: { + ...baseAuthSchema, + required: [...baseAuthSchema.required, "credentials"], + properties: { + ...baseAuthSchema.properties, + credentials: { + type: "object", + title: "Accounts credentials", + required: ["username", "password"], + properties: { + username: { + type: "string", + title: "Username", + }, + password: { + type: "string", + title: "Password", + }, + }, + }, + }, + }, + uiSchema: { + ...baseUISchema, + credentials: { + password: { "ui:widget": "password" }, + }, + }, + }, basicauth: { schema: { ...baseAuthSchema, @@ -229,6 +259,7 @@ const authSchemas = { const authLabels = { anonymous: "Anonymous", basicauth: "Basic Auth", + account: "Kinto Account Auth", fxa: "Firefox Account", ldap: "LDAP", portier: "Portier", @@ -352,6 +383,7 @@ export default class AuthForm extends PureComponent { // case "anonymous": // case "ldap": // case "basicauth": + // case "account": default: { return setup(extendedFormData); } diff --git a/src/reducers/settings.js b/src/reducers/settings.js index bb311de07..6ec49cf8c 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -4,7 +4,7 @@ import type { SettingsState } from "../types"; const INITIAL_STATE: SettingsState = { maxPerPage: 200, singleServer: null, - authMethods: ["basicauth", "fxa", "ldap", "portier", "anonymous"], + authMethods: ["basicauth", "account", "fxa", "ldap", "portier", "anonymous"], sidebarMaxListedCollections: 10, }; diff --git a/src/types.js b/src/types.js index 730385228..0d8662c8c 100644 --- a/src/types.js +++ b/src/types.js @@ -286,7 +286,13 @@ export type RouteResources = { group: ?GroupResource, }; -export type AuthMethod = "anonymous" | "fxa" | "ldap" | "basicauth" | "portier"; +export type AuthMethod = + | "anonymous" + | "account" + | "fxa" + | "ldap" + | "basicauth" + | "portier"; export type SettingsState = { maxPerPage: number, @@ -295,7 +301,12 @@ export type SettingsState = { sidebarMaxListedCollections: number, }; -export type AuthData = AnonymousAuth | LDAPAuth | BasicAuth | TokenAuth; +export type AuthData = + | AnonymousAuth + | LDAPAuth + | AccountAuth + | BasicAuth + | TokenAuth; export type AnonymousAuth = { authType: "anonymous", @@ -311,6 +322,15 @@ export type LDAPAuth = { }, }; +export type AccountAuth = { + authType: "account", + server: string, + credentials: { + username: string, + password: string, + }, +}; + export type BasicAuth = { authType: "basicauth", server: string,