Skip to content

Commit

Permalink
Add support for the Kinto Account plugin. Fixes #436
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Jun 23, 2017
1 parent 10ae9eb commit 554445d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
34 changes: 33 additions & 1 deletion src/components/AuthForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const baseAuthSchema = {
authType: {
type: "string",
title: "Authentication method",
enum: ["basicauth", "fxa", "ldap"],
enum: ["basicauth", "account", "fxa", "ldap"],
},
},
};
Expand All @@ -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,
Expand Down Expand Up @@ -229,6 +259,7 @@ const authSchemas = {
const authLabels = {
anonymous: "Anonymous",
basicauth: "Basic Auth",
account: "Kinto Account Auth",
fxa: "Firefox Account",
ldap: "LDAP",
portier: "Portier",
Expand Down Expand Up @@ -352,6 +383,7 @@ export default class AuthForm extends PureComponent {
// case "anonymous":
// case "ldap":
// case "basicauth":
// case "account":
default: {
return setup(extendedFormData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
24 changes: 22 additions & 2 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand Down

0 comments on commit 554445d

Please sign in to comment.