Merge pull request #130 from clems4ever/revert-filesystem-notifier

Revert filesystem notifier
pull/140/head
Clément Michaud 2017-10-09 01:58:06 +02:00 committed by GitHub
commit 2641fb1620
4 changed files with 36 additions and 0 deletions

View File

@ -148,6 +148,8 @@ Click on **Continue** and you'll get your secret in QRCode and Base32 formats. Y
[Google Authenticator] [Google Authenticator]
to store them and get the generated tokens with the app. to store them and get the generated tokens with the app.
**Note:** If you're testing with **npm**, you will not have access to the fake webmail. You can use the filesystem notifier (option available [config.template.yml]) that will create a file containing the validation URL instead of sending an email. Please only use it for testing.
<img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/totp.png" width="400"> <img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/totp.png" width="400">
### Second factor with U2F security keys ### Second factor with U2F security keys
@ -163,6 +165,8 @@ Click on **Continue** and you'll be asking to touch the token of your device
to register. Upon successful registration, you can authenticate using your U2F to register. Upon successful registration, you can authenticate using your U2F
device by simply touching the token. Easy, right?! device by simply touching the token. Easy, right?!
**Note:** If you're testing with **npm**, you will not have access to the fake webmail. You can use the filesystem notifier (option available [config.template.yml]) that will create a file containing the validation URL instead of sending an email. Please only use it for testing.
<img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/u2f.png" width="400"> <img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/u2f.png" width="400">
### Password reset ### Password reset
@ -173,6 +177,8 @@ email address. For the sake of the example, the email is delivered in a fake web
for you and accessible at [http://localhost:8085](http://localhost:8085). for you and accessible at [http://localhost:8085](http://localhost:8085).
Paste the link in your browser and you should be able to reset the password. Paste the link in your browser and you should be able to reset the password.
**Note:** If you're testing with **npm**, you will not have access to the fake webmail. You can use the filesystem notifier (option available [config.template.yml]) that will create a file containing the validation URL instead of sending an email. Please only use it for testing.
<img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/reset_password.png" width="400"> <img src="https://raw.githubusercontent.com/clems4ever/authelia/master/images/reset_password.png" width="400">
### Access Control ### Access Control

View File

@ -182,6 +182,10 @@ storage:
# registration or a TOTP registration. # registration or a TOTP registration.
# Use only an available configuration: filesystem, gmail # Use only an available configuration: filesystem, gmail
notifier: notifier:
# For testing purpose, notifications can be sent in a file
# filesystem:
# filename: /tmp/authelia/notification.txt
# Use your gmail account to send the notifications. You can use an app password. # Use your gmail account to send the notifications. You can use an app password.
# gmail: # gmail:
# username: user@example.com # username: user@example.com

View File

@ -0,0 +1,22 @@
import * as BluebirdPromise from "bluebird";
import * as util from "util";
import * as Fs from "fs";
import { INotifier } from "./INotifier";
import { Identity } from "../../../types/Identity";
import { FileSystemNotifierConfiguration } from "../configuration/Configuration";
export class FileSystemNotifier implements INotifier {
private filename: string;
constructor(options: FileSystemNotifierConfiguration) {
this.filename = options.filename;
}
notify(identity: Identity, subject: string, link: string): BluebirdPromise<void> {
const content = util.format("Date: %s\nUser: %s\nSubject: %s\nLink: %s", new Date().toString(), identity.userid,
subject, link);
const writeFilePromised: any = BluebirdPromise.promisify(Fs.writeFile);
return writeFilePromised(this.filename, content);
}
}

View File

@ -3,6 +3,7 @@ import { NotifierConfiguration } from "../configuration/Configuration";
import Nodemailer = require("nodemailer"); import Nodemailer = require("nodemailer");
import { INotifier } from "./INotifier"; import { INotifier } from "./INotifier";
import { FileSystemNotifier } from "./FileSystemNotifier";
import { GMailNotifier } from "./GMailNotifier"; import { GMailNotifier } from "./GMailNotifier";
import { SmtpNotifier } from "./SmtpNotifier"; import { SmtpNotifier } from "./SmtpNotifier";
import { IMailSender } from "./IMailSender"; import { IMailSender } from "./IMailSender";
@ -18,6 +19,9 @@ export class NotifierFactory {
const mailSender = mailSenderBuilder.buildSmtp(options.smtp); const mailSender = mailSenderBuilder.buildSmtp(options.smtp);
return new SmtpNotifier(options.smtp, mailSender); return new SmtpNotifier(options.smtp, mailSender);
} }
else if ("filesystem" in options) {
return new FileSystemNotifier(options.filesystem);
}
else { else {
throw new Error("No available notifier option detected."); throw new Error("No available notifier option detected.");
} }