├── .eslintrc.js ├── .github ├── pull_request_template.md └── workflows │ ├── codeql-analysis.yml │ ├── lint.yml │ ├── node.yml │ └── static-analysis.yml ├── .gitignore ├── .nextcloudignore ├── .php-cs-fixer.dist.php ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SECURITY.md ├── appinfo ├── info.xml └── routes.php ├── babel.config.json ├── composer.json ├── composer.lock ├── img ├── app-dark.svg └── app.svg ├── krankerl.toml ├── l10n ├── 2json.sh ├── de.js ├── fr.js ├── pt_BR.js ├── ru.js └── tr.js ├── lib ├── AppInfo │ └── Application.php ├── Controller │ └── SettingsController.php ├── Exception │ ├── TransmissionException.php │ └── VerificationException.php ├── Provider │ ├── Email.php │ └── State.php ├── Service │ ├── Email.php │ ├── SetupService.php │ └── StateStorage.php └── Settings │ └── PersonalSettings.php ├── package-lock.json ├── package.json ├── psalm.xml ├── screenshots ├── challenge.png ├── select-auth_thumb.png ├── settings-after.png └── settings-before.png ├── src ├── components │ ├── GatewaySettings.vue │ └── L10n.vue ├── init.js ├── service │ └── registration.js ├── views │ └── EmailSettings.vue ├── webpack.base.config.js ├── webpack.dev.config.js └── webpack.prod.config.js ├── templates ├── challenge.php ├── error.php └── personal_settings.php └── tests └── psalm-baseline.xml /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | '@nextcloud' 4 | ] 5 | }; 6 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | 4 | ## Related Issues 5 | 6 | Closes #XXX 7 | 8 | ## Contributor's checklist 9 | - [ ] Description states the purpose of the modifications 10 | - [ ] The PR contains only relevant modifications 11 | - [ ] Issues are linked (if applicable) 12 | - [ ] PHP-Code adheres to [PSR-12](https://www.php-fig.org/psr/psr-12/) 13 | - [ ] JS-Code adheres to [standardJS](https://standardjs.com/index.html) 14 | - [ ] Commits are atomic with a clear description 15 | - [ ] Changelog contains a user-centric summary 16 | - [ ] All modifications are tested (think of edge cases) 17 | - [ ] GitHub actions succeed 18 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '28 16 * * 2' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | permissions: 29 | actions: read 30 | contents: read 31 | security-events: write 32 | 33 | strategy: 34 | fail-fast: false 35 | matrix: 36 | language: [ 'javascript' ] 37 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 38 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v3 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v3 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v3 72 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | - stable* 9 | 10 | jobs: 11 | php: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | php: 16 | - '8.1' 17 | - '8.3' 18 | - '8.4' 19 | name: php${{ matrix.php }} 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Set up php ${{ matrix.php }} 23 | uses: shivammathur/setup-php@v2 24 | with: 25 | php-version: ${{ matrix.php }} 26 | coverage: none 27 | - name: Lint 28 | run: composer run lint 29 | 30 | node: 31 | runs-on: ubuntu-latest 32 | strategy: 33 | matrix: 34 | node: 35 | - '16.x' 36 | - '18.x' 37 | - '19.x' 38 | name: node${{ matrix.node }} 39 | steps: 40 | - uses: actions/checkout@v4 41 | - name: Set up node ${{ matrix.node }} 42 | uses: actions/setup-node@v1 43 | with: 44 | node-version: ${{ matrix.node }} 45 | - name: Install dependencies 46 | run: npm ci 47 | - name: Lint 48 | run: npm run lint 49 | 50 | php-cs-fixer: 51 | name: php-cs check 52 | runs-on: ubuntu-latest 53 | steps: 54 | - name: Checkout 55 | uses: actions/checkout@v4 56 | - name: Set up php 57 | uses: shivammathur/setup-php@v2 58 | with: 59 | php-version: 8.1 60 | tools: composer:v2 61 | coverage: none 62 | - name: Install dependencies 63 | run: composer install 64 | - name: Run coding standards check 65 | run: composer run cs:check 66 | -------------------------------------------------------------------------------- /.github/workflows/node.yml: -------------------------------------------------------------------------------- 1 | name: Node 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | - stable* 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-versions: 17 | - '16.x' 18 | - '18.x' 19 | - '19.x' 20 | 21 | name: node${{ matrix.node-versions }} 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Set up node ${{ matrix.node-versions }} 26 | uses: actions/setup-node@v1 27 | with: 28 | node-version: ${{ matrix.node-versions }} 29 | 30 | - name: Install dependencies & build 31 | run: | 32 | npm ci 33 | npm run build --if-present 34 | 35 | - name: Check webpack build changes 36 | run: | 37 | bash -c "[[ ! \"`git status --porcelain `\" ]] || ( echo 'Uncommited changes in webpack build' && git status && exit 1 )" 38 | -------------------------------------------------------------------------------- /.github/workflows/static-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Static analysis 2 | 3 | on: 4 | - pull_request 5 | 6 | jobs: 7 | static-psalm-analysis: 8 | runs-on: ubuntu-latest 9 | strategy: 10 | matrix: # https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs 11 | ocp: 12 | - 'dev-stable29' 13 | - 'dev-stable30' 14 | - 'dev-stable31' 15 | - 'dev-master' 16 | php: 17 | - '8.1' 18 | - '8.3' 19 | - '8.4' 20 | include: 21 | - ocp: 'dev-stable29' 22 | php: '8.1' 23 | - ocp: 'dev-stable30' 24 | php: '8.3' 25 | - ocp: 'dev-stable31' 26 | php: '8.3' 27 | - ocp: 'dev-master' 28 | php: '8.4' 29 | 30 | name: Nextcloud ${{ matrix.ocp }} on PHP ${{ matrix.php }} 31 | steps: 32 | - name: Checkout 33 | uses: actions/checkout@master 34 | - name: Set up php 35 | uses: shivammathur/setup-php@v2 36 | with: 37 | php-version: "${{ matrix.php }}" 38 | tools: composer:v2 39 | coverage: none 40 | - name: Remove PHP lockfile 41 | run: rm composer.lock 42 | - name: Install dependencies 43 | run: composer require --dev nextcloud/ocp:${{ matrix.ocp }} 44 | - name: Run coding standards check 45 | run: composer run -- psalm --php-version=${{ matrix.php }} 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /appinfo/signature.json 2 | /build/ 3 | /js/ 4 | /l10n/*.json 5 | /node-modules/ 6 | /node_modules/ 7 | /signed/ 8 | /translationfiles 9 | /translationtool.phar 10 | vendor/ 11 | .php-cs-fixer.cache 12 | /appinfo/Archiv* 13 | /img/Archiv* 14 | /screenshots/Archiv* 15 | .idea/ 16 | *.iml 17 | -------------------------------------------------------------------------------- /.nextcloudignore: -------------------------------------------------------------------------------- 1 | /.eslintrc.js 2 | /.git 3 | /.github 4 | /.gitignore 5 | /.nextcloudignore 6 | /.php-cs-fixer.dist.php 7 | /.php-cs-fixer.cache 8 | /build 9 | /babel.config.json 10 | /composer.* 11 | /krankerl.toml 12 | /l10n/2json.sh 13 | /node_modules 14 | /package* 15 | /psalm.xml 16 | /screenshots 17 | /src 18 | /tests 19 | /vendor/bin 20 | /screenshots 21 | -------------------------------------------------------------------------------- /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | getFinder() 12 | ->ignoreVCSIgnored(true) 13 | ->notPath('build') 14 | ->notPath('l10n') 15 | ->notPath('lib/Vendor') 16 | ->notPath('src') 17 | ->notPath('vendor') 18 | ->in(__DIR__); 19 | return $config; 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | Notable changes in [changelog format](https://keepachangelog.com/en/1.0.0/), project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) 3 | 4 | ## 2.8.0 (2025-03-16) 5 | 6 | ### Added 7 | 8 | - Support for Nextcloud 29 to 31 9 | - Support for PHP 8.4 10 | 11 | ### Removed 12 | 13 | - Support for Nextcloud 24 to 28 14 | 15 | ## 2.7.4 (2023-11-06) 16 | 17 | ### Added 18 | 19 | - Support for Nextcloud 28 (tested against beta1) 20 | - Support for PHP 8.3 21 | 22 | ## 2.7.3 (2023-05-20) 23 | 24 | ### Added 25 | 26 | - Support for Nextcloud 27 (tested against RC1) 27 | 28 | ## 2.7.2 (2023-03-04) 29 | 30 | ### Added 31 | 32 | - Support for Nextcloud 26 (tested against RC1) 33 | - Support for PHP 8.2 34 | 35 | ### Removed 36 | 37 | - Support for Nextcloud 22 and 23 38 | - Support for PHP 7.4 39 | 40 | None of these recommended changes have been implemented yet: 41 | https://github.com/nextcloud/server/issues/34692 42 | 43 | ## 2.7.1 (2022-10-16) 44 | 45 | ### Changed 46 | 47 | - Fix Russian translation (Artyom) 48 | - Support for Nextcloud 25 (tested against RC5) 49 | 50 | Until further notice, this v2 branch is maintained as legacy. 51 | Volunteers needed for the ongoing v3 re-write based on twofactor_totp. 52 | 53 | ## 2.7.0 (2022-09-20) 54 | 55 | ### Added 56 | 57 | - Brazilian Portuguese translation (José A. Marteline Cavalcante) 58 | 59 | ### Changed 60 | 61 | - correct light/dark icons 62 | 63 | ### Removed 64 | 65 | - Support for PHP 7.3 66 | 67 | ## 2.6.0 (2022-09-04) 68 | 69 | ### Added 70 | 71 | - Support for Nextcloud 25 (tested against beta 4) 72 | 73 | ### Changed 74 | 75 | - material-design-icon as app icon, avoid to use it in-app 76 | - replace verification by authentication where applicable 77 | 78 | ### Removed 79 | 80 | - Support for Nextcloud 21 81 | 82 | ## 2.5.0 (2022-06-25) 83 | 84 | ### Added 85 | 86 | - Turkish translation (@ersen0) 87 | 88 | ## 2.4.0 (2022-05-11) 89 | 90 | ### Added 91 | 92 | - French translation (@ArchaicHammer) 93 | 94 | ## 2.3.0 (2022-04-15) 95 | 96 | ### Added 97 | 98 | - Russian translation (@jensaymoo) 99 | 100 | ## 2.2.0 (2022-04-05) 101 | 102 | ### Added 103 | 104 | - Support for Nextcloud 24 (tested against beta 2) 105 | - Support for PHP 8.1 106 | - German app description 107 | 108 | ### Changed 109 | 110 | - Don't show email address in 2FA 111 | - Re-add submit button in 2FA 112 | 113 | ### Removed 114 | 115 | - Support for Nextcloud 19 and 20 116 | - Support for PHP 7.2 117 | 118 | ### Security 119 | 120 | - Update libraries 121 | 122 | ## 2.1.1 (2021-09-28) 123 | 124 | ### Added 125 | 126 | - Support for Nextcloud 23 127 | 128 | ### Changed 129 | 130 | - UI: new app icon, rephrase strings 131 | 132 | ## 2.1.0 (2021-09-11) 133 | 134 | Note: Version 2.1.0 (store) = 2.0.1 (GitHub) 135 | 136 | ### Added 137 | 138 | - Support for Nextcloud 22 139 | 140 | ## 2.0.0 (2020-12-23) 141 | 142 | ### Added 143 | 144 | - Support for Nextcloud 21 145 | - Support for PHP 8.0 146 | - Static code analysis and code standard checks 147 | 148 | ### Removed 149 | 150 | - Support for Nextcloud 18 151 | - Support for PHP 7.1 152 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Two-Factor Email Provider for Nextcloud 2 | 3 | [Nextcloud](https://nextcloud.com/) supports web logins with [two factor authentication](https://en.wikipedia.org/wiki/Multi-factor_authentication#Factors) (2FA). To support a certain type of 2nd factor, an add-on server-app "2FA provider" must be installed. This is the current Two-Factor Email Provider for Nextcloud (see below). 4 | 5 | It kicks in after the primary authentication stage (typically username and password). It challenges the user to enter a 6-digit authentication code (aka one-time password, OTP) - a code that is randomly generated and sent to the user's primary email address by this [Nextcloud App (category Security)](https://apps.nextcloud.com/categories/security). 6 | 7 | Currently this app must be installed by an admin and must be enabled by the user. It currently uses the primary email address set in 'Personal info' and cannot be activated if none is set there. There is an issue that argues that using the primary notification address poses a security risk (to be discussed). 8 | 9 | It currently cannot be used on first login when two-factor authentication is enforced (not implemented yet). It might be enhanced to enable admins to enforce 2FA via email for new (and existing?) users. Any pull requests or offers to help are welcome, please contact the maintainer (see [wiki](https://github.com/nursoda/twofactor_email/wiki/Developer-notes)). 10 | 11 | The easiest way to install this app is to select "Apps" from the menu (as admin) and search for "two", then install it (which will retrieve it from the [App Store](https://apps.nextcloud.com/apps/twofactor_email)). 12 | 13 | ## State of the app 14 | 15 | The version 2.x ("v2") of this app was not updated for quite a while and left admins and their users in an uncomfortable situation. I am sorry for that and try not to let that happen again. This app was never and is not abandoned. But it is merely in a feature freeze state. I will just make sure it's secure¹ and works for officially supported Nextcloud versions. 16 | 17 | ¹Security: I am aware that this app has npm security warnings when building it. This in not due to my code but due to Nextcloud dependencies still relying on vue2, which is EOL since end of 2023 (and that EOL was annonced more than a year before that). When resolving dependencies, packages are used that do have known issues. Most of them are development dependencies "only" (meaning that potentially vulnerable code is not in the build code, but only used when building it) - with one notable exception: vue2. 18 | 19 | So, I ask all volunteers to work with Nextcloud projects to get rid of vue2. If you want to enhance this app, please contact me, and put your efforts in the version 3 ("v3") of this app, which now lives in my company's repository [datenschutz-individuell/twofactor_email](https://github.com/datenschutz-individuell/twofactor_email). 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | I only support the latest version of the app for all Nextcloud versions that still have official support. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | You may use GitHub to report security vulnerabilities unless you feel that it is not easily fixable and would affect many users. 10 | In this case, please email me directly using olav at seyfarth dot de. There is an OpenPGP key available for this address at https://keys.openpgp.org/ that you may use. 11 | 12 | ## Bounty 13 | 14 | Since I am doing this as a hobby project, I cannot provide any bounty for reporting, sorry. 15 | -------------------------------------------------------------------------------- /appinfo/info.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | twofactor_email 4 | 2.8.0 5 | 6 | 7 | 8 | 9 | https://github.com/nursoda/twofactor_email.git 10 | agpl 11 | Olav Seyfarth (current maintainer) 12 | Roeland Jago Douma (original author) 13 | security 14 | TwoFactorEmail 15 | 16 | OCA\TwoFactorEmail\Provider\Email 17 | 18 | https://github.com/nursoda/twofactor_email 19 | https://github.com/nursoda/twofactor_email/issues 20 | 21 | https://github.com/nursoda/twofactor_email/wiki/User-manual 22 | https://github.com/nursoda/twofactor_email/wiki/Admin-manual 23 | https://github.com/nursoda/twofactor_email/wiki/Developer-notes 24 | 25 | https://raw.githubusercontent.com/nursoda/twofactor_email/v2/screenshots/challenge.png 26 | https://raw.githubusercontent.com/nursoda/twofactor_email/v2/screenshots/settings-before.png 27 | https://raw.githubusercontent.com/nursoda/twofactor_email/v2/screenshots/settings-after.png 28 | Two-Factor Email 29 | Two-Factor Email Provider 30 | Service de double authentification par email 31 | Zwei-Faktor E-Mail Provider 32 | Поставщик двухфакторной аутентификации по E-mail 33 | İki Aşamalı E-posta Sağlayıcısı 34 | Provedor de autenticação de dois fatores via e-mail 35 | This app allows users to set up email as a second factor for web logins. It requires that an email address is set in 'Personal info'. It currently cannot be used on first login when two-factor authentication is enforced (not implemented yet). 36 | Diese App ermöglicht es Benutzern, E-Mail als zweiten Faktor für Webanmeldungen einzurichten. Sie setzt voraus, dass eine E-Mail-Adresse in den persönlichen Einstellungen hinterlegt ist. Sie kann derzeit nicht für die erste Anmeldung verwendet werden, wenn die Zwei-Faktor-Authentifizierung erzwungen wird. 37 | Это приложение позволяет пользователям настроить электронную почту в качестве второго фактора для входа в систему через Интернет. Для этого необходимо, чтобы адрес электронной почты был сохранен в разделе «Личная информация». В настоящее время его нельзя использовать для первого входа в систему, если принудительно применяется двухфакторная аутентификация. 38 | Cette application permet aux utilisateurs d'activer la double authentification par email lors de la connexion web. Une adresse mail doit être configurée dans les 'Infos personelles'. Ce module ne peut pas être utilisé pour les premières connexion quand la double authentification est forcée (Ce n'est pas encore implémentée). 39 | Bu uygulama, kullanıcıların internet üzerinden oturum açmak için ikinci bir aşama olarak e-posta ayarlamasına olanak tanır. 'Kişisel bilgiler' bölümünde bir e-posta adresinin ayarlanmış olmasını gerektirir. Şu anda iki aşamalı kimlik doğrulama zorunlu tutulduğunda ilk oturum açmada kullanılamıyor (henüz uygulanmadı). 40 | Este aplicativo permite que os usuários configurem o e-mail como um segundo fator para logins via web. É necessário que um e-mail seja definido em 'Informações pessoais'. Atualmente não pode ser utilizado no primeiro login, se a autenticação de dois fatores for forçada nesta situação (ainda não implementado). 41 | -------------------------------------------------------------------------------- /appinfo/routes.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * @author Roeland Jago Douma 8 | * 9 | * @license GNU AGPL version 3 or any later version 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Affero General Public License as 13 | * published by the Free Software Foundation, either version 3 of the 14 | * License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Affero General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Affero General Public License 22 | * along with this program. If not, see . 23 | * 24 | */ 25 | 26 | return [ 27 | 'routes' => [ 28 | [ 29 | 'name' => 'settings#startVerification', 30 | 'url' => '/settings/enable', 31 | 'verb' => 'POST' 32 | ], 33 | [ 34 | 'name' => 'settings#revokeVerification', 35 | 'url' => '/settings/disable', 36 | 'verb' => 'DELETE' 37 | ], 38 | [ 39 | 'name' => 'settings#finishVerification', 40 | 'url' => '/settings/validate', 41 | 'verb' => 'POST' 42 | ] 43 | ] 44 | ]; 45 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env"] 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "optimize-autoloader": true, 4 | "classmap-authoritative": true 5 | }, 6 | "scripts": { 7 | "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", 8 | "cs:check": "php-cs-fixer fix --dry-run --diff", 9 | "cs:fix": "php-cs-fixer fix", 10 | "psalm": "psalm.phar" 11 | }, 12 | "require-dev": { 13 | "nextcloud/ocp": "dev-master", 14 | "nextcloud/coding-standard": "dev-master", 15 | "psalm/phar": "dev-master" 16 | }, 17 | "require": { 18 | "php": ">=8.0 <8.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "fbc7d53fe027e25e05e6fee1b196afaf", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "kubawerlos/php-cs-fixer-custom-fixers", 12 | "version": "v3.23.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", 16 | "reference": "b3210c6e546bdfc95664297a8971ae3b6b1f4a5a" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/b3210c6e546bdfc95664297a8971ae3b6b1f4a5a", 21 | "reference": "b3210c6e546bdfc95664297a8971ae3b6b1f4a5a", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "ext-filter": "*", 26 | "ext-tokenizer": "*", 27 | "friendsofphp/php-cs-fixer": "^3.61.1", 28 | "php": "^7.4 || ^8.0" 29 | }, 30 | "require-dev": { 31 | "phpunit/phpunit": "^9.6.4 || ^10.5.29" 32 | }, 33 | "type": "library", 34 | "autoload": { 35 | "psr-4": { 36 | "PhpCsFixerCustomFixers\\": "src" 37 | } 38 | }, 39 | "notification-url": "https://packagist.org/downloads/", 40 | "license": [ 41 | "MIT" 42 | ], 43 | "authors": [ 44 | { 45 | "name": "Kuba Werłos", 46 | "email": "werlos@gmail.com" 47 | } 48 | ], 49 | "description": "A set of custom fixers for PHP CS Fixer", 50 | "support": { 51 | "issues": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues", 52 | "source": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/tree/v3.23.0" 53 | }, 54 | "time": "2025-02-15T09:15:56+00:00" 55 | }, 56 | { 57 | "name": "nextcloud/coding-standard", 58 | "version": "dev-master", 59 | "source": { 60 | "type": "git", 61 | "url": "https://github.com/nextcloud/coding-standard.git", 62 | "reference": "e2a9dbe871adfd5df54e044418ef1847b2b58a2b" 63 | }, 64 | "dist": { 65 | "type": "zip", 66 | "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/e2a9dbe871adfd5df54e044418ef1847b2b58a2b", 67 | "reference": "e2a9dbe871adfd5df54e044418ef1847b2b58a2b", 68 | "shasum": "" 69 | }, 70 | "require": { 71 | "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", 72 | "php": "^8.0", 73 | "php-cs-fixer/shim": "^3.17" 74 | }, 75 | "default-branch": true, 76 | "type": "library", 77 | "autoload": { 78 | "psr-4": { 79 | "Nextcloud\\CodingStandard\\": "src" 80 | } 81 | }, 82 | "notification-url": "https://packagist.org/downloads/", 83 | "license": [ 84 | "MIT" 85 | ], 86 | "authors": [ 87 | { 88 | "name": "Christoph Wurst", 89 | "email": "christoph@winzerhof-wurst.at" 90 | } 91 | ], 92 | "description": "Nextcloud coding standards for the php cs fixer", 93 | "support": { 94 | "issues": "https://github.com/nextcloud/coding-standard/issues", 95 | "source": "https://github.com/nextcloud/coding-standard/tree/master" 96 | }, 97 | "time": "2025-01-17T19:29:22+00:00" 98 | }, 99 | { 100 | "name": "nextcloud/ocp", 101 | "version": "dev-master", 102 | "source": { 103 | "type": "git", 104 | "url": "https://github.com/nextcloud-deps/ocp.git", 105 | "reference": "dc5473e3895d859535de45eab15d2095cb8eafe4" 106 | }, 107 | "dist": { 108 | "type": "zip", 109 | "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/dc5473e3895d859535de45eab15d2095cb8eafe4", 110 | "reference": "dc5473e3895d859535de45eab15d2095cb8eafe4", 111 | "shasum": "" 112 | }, 113 | "require": { 114 | "php": "~8.1 || ~8.2 || ~8.3 || ~8.4", 115 | "psr/clock": "^1.0", 116 | "psr/container": "^2.0.2", 117 | "psr/event-dispatcher": "^1.0", 118 | "psr/log": "^3.0.2" 119 | }, 120 | "default-branch": true, 121 | "type": "library", 122 | "extra": { 123 | "branch-alias": { 124 | "dev-master": "32.0.0-dev" 125 | } 126 | }, 127 | "notification-url": "https://packagist.org/downloads/", 128 | "license": [ 129 | "AGPL-3.0-or-later" 130 | ], 131 | "authors": [ 132 | { 133 | "name": "Christoph Wurst", 134 | "email": "christoph@winzerhof-wurst.at" 135 | }, 136 | { 137 | "name": "Joas Schilling", 138 | "email": "coding@schilljs.com" 139 | } 140 | ], 141 | "description": "Composer package containing Nextcloud's public OCP API and the unstable NCU API", 142 | "support": { 143 | "issues": "https://github.com/nextcloud-deps/ocp/issues", 144 | "source": "https://github.com/nextcloud-deps/ocp/tree/master" 145 | }, 146 | "time": "2025-03-11T00:46:19+00:00" 147 | }, 148 | { 149 | "name": "php-cs-fixer/shim", 150 | "version": "v3.72.0", 151 | "source": { 152 | "type": "git", 153 | "url": "https://github.com/PHP-CS-Fixer/shim.git", 154 | "reference": "f5131b7a7d0103919a1b478a2763bd76c98e472e" 155 | }, 156 | "dist": { 157 | "type": "zip", 158 | "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/f5131b7a7d0103919a1b478a2763bd76c98e472e", 159 | "reference": "f5131b7a7d0103919a1b478a2763bd76c98e472e", 160 | "shasum": "" 161 | }, 162 | "require": { 163 | "ext-json": "*", 164 | "ext-tokenizer": "*", 165 | "php": "^7.4 || ^8.0" 166 | }, 167 | "replace": { 168 | "friendsofphp/php-cs-fixer": "self.version" 169 | }, 170 | "suggest": { 171 | "ext-dom": "For handling output formats in XML", 172 | "ext-mbstring": "For handling non-UTF8 characters." 173 | }, 174 | "bin": [ 175 | "php-cs-fixer", 176 | "php-cs-fixer.phar" 177 | ], 178 | "type": "application", 179 | "notification-url": "https://packagist.org/downloads/", 180 | "license": [ 181 | "MIT" 182 | ], 183 | "authors": [ 184 | { 185 | "name": "Fabien Potencier", 186 | "email": "fabien@symfony.com" 187 | }, 188 | { 189 | "name": "Dariusz Rumiński", 190 | "email": "dariusz.ruminski@gmail.com" 191 | } 192 | ], 193 | "description": "A tool to automatically fix PHP code style", 194 | "support": { 195 | "issues": "https://github.com/PHP-CS-Fixer/shim/issues", 196 | "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.72.0" 197 | }, 198 | "time": "2025-03-13T11:26:00+00:00" 199 | }, 200 | { 201 | "name": "psalm/phar", 202 | "version": "dev-master", 203 | "source": { 204 | "type": "git", 205 | "url": "https://github.com/psalm/phar.git", 206 | "reference": "42f694ac03cb1ff9018177a1c3696f600426ecc1" 207 | }, 208 | "dist": { 209 | "type": "zip", 210 | "url": "https://api.github.com/repos/psalm/phar/zipball/42f694ac03cb1ff9018177a1c3696f600426ecc1", 211 | "reference": "42f694ac03cb1ff9018177a1c3696f600426ecc1", 212 | "shasum": "" 213 | }, 214 | "require": { 215 | "php": "^8.2" 216 | }, 217 | "conflict": { 218 | "vimeo/psalm": "*" 219 | }, 220 | "default-branch": true, 221 | "bin": [ 222 | "psalm.phar" 223 | ], 224 | "type": "library", 225 | "notification-url": "https://packagist.org/downloads/", 226 | "license": [ 227 | "MIT" 228 | ], 229 | "description": "Composer-based Psalm Phar", 230 | "support": { 231 | "issues": "https://github.com/psalm/phar/issues", 232 | "source": "https://github.com/psalm/phar/tree/master" 233 | }, 234 | "time": "2025-03-14T20:10:36+00:00" 235 | }, 236 | { 237 | "name": "psr/clock", 238 | "version": "1.0.0", 239 | "source": { 240 | "type": "git", 241 | "url": "https://github.com/php-fig/clock.git", 242 | "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d" 243 | }, 244 | "dist": { 245 | "type": "zip", 246 | "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d", 247 | "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d", 248 | "shasum": "" 249 | }, 250 | "require": { 251 | "php": "^7.0 || ^8.0" 252 | }, 253 | "type": "library", 254 | "autoload": { 255 | "psr-4": { 256 | "Psr\\Clock\\": "src/" 257 | } 258 | }, 259 | "notification-url": "https://packagist.org/downloads/", 260 | "license": [ 261 | "MIT" 262 | ], 263 | "authors": [ 264 | { 265 | "name": "PHP-FIG", 266 | "homepage": "https://www.php-fig.org/" 267 | } 268 | ], 269 | "description": "Common interface for reading the clock.", 270 | "homepage": "https://github.com/php-fig/clock", 271 | "keywords": [ 272 | "clock", 273 | "now", 274 | "psr", 275 | "psr-20", 276 | "time" 277 | ], 278 | "support": { 279 | "issues": "https://github.com/php-fig/clock/issues", 280 | "source": "https://github.com/php-fig/clock/tree/1.0.0" 281 | }, 282 | "time": "2022-11-25T14:36:26+00:00" 283 | }, 284 | { 285 | "name": "psr/container", 286 | "version": "2.0.2", 287 | "source": { 288 | "type": "git", 289 | "url": "https://github.com/php-fig/container.git", 290 | "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" 291 | }, 292 | "dist": { 293 | "type": "zip", 294 | "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", 295 | "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", 296 | "shasum": "" 297 | }, 298 | "require": { 299 | "php": ">=7.4.0" 300 | }, 301 | "type": "library", 302 | "extra": { 303 | "branch-alias": { 304 | "dev-master": "2.0.x-dev" 305 | } 306 | }, 307 | "autoload": { 308 | "psr-4": { 309 | "Psr\\Container\\": "src/" 310 | } 311 | }, 312 | "notification-url": "https://packagist.org/downloads/", 313 | "license": [ 314 | "MIT" 315 | ], 316 | "authors": [ 317 | { 318 | "name": "PHP-FIG", 319 | "homepage": "https://www.php-fig.org/" 320 | } 321 | ], 322 | "description": "Common Container Interface (PHP FIG PSR-11)", 323 | "homepage": "https://github.com/php-fig/container", 324 | "keywords": [ 325 | "PSR-11", 326 | "container", 327 | "container-interface", 328 | "container-interop", 329 | "psr" 330 | ], 331 | "support": { 332 | "issues": "https://github.com/php-fig/container/issues", 333 | "source": "https://github.com/php-fig/container/tree/2.0.2" 334 | }, 335 | "time": "2021-11-05T16:47:00+00:00" 336 | }, 337 | { 338 | "name": "psr/event-dispatcher", 339 | "version": "1.0.0", 340 | "source": { 341 | "type": "git", 342 | "url": "https://github.com/php-fig/event-dispatcher.git", 343 | "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" 344 | }, 345 | "dist": { 346 | "type": "zip", 347 | "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", 348 | "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", 349 | "shasum": "" 350 | }, 351 | "require": { 352 | "php": ">=7.2.0" 353 | }, 354 | "type": "library", 355 | "extra": { 356 | "branch-alias": { 357 | "dev-master": "1.0.x-dev" 358 | } 359 | }, 360 | "autoload": { 361 | "psr-4": { 362 | "Psr\\EventDispatcher\\": "src/" 363 | } 364 | }, 365 | "notification-url": "https://packagist.org/downloads/", 366 | "license": [ 367 | "MIT" 368 | ], 369 | "authors": [ 370 | { 371 | "name": "PHP-FIG", 372 | "homepage": "http://www.php-fig.org/" 373 | } 374 | ], 375 | "description": "Standard interfaces for event handling.", 376 | "keywords": [ 377 | "events", 378 | "psr", 379 | "psr-14" 380 | ], 381 | "support": { 382 | "issues": "https://github.com/php-fig/event-dispatcher/issues", 383 | "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" 384 | }, 385 | "time": "2019-01-08T18:20:26+00:00" 386 | }, 387 | { 388 | "name": "psr/log", 389 | "version": "3.0.2", 390 | "source": { 391 | "type": "git", 392 | "url": "https://github.com/php-fig/log.git", 393 | "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" 394 | }, 395 | "dist": { 396 | "type": "zip", 397 | "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", 398 | "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", 399 | "shasum": "" 400 | }, 401 | "require": { 402 | "php": ">=8.0.0" 403 | }, 404 | "type": "library", 405 | "extra": { 406 | "branch-alias": { 407 | "dev-master": "3.x-dev" 408 | } 409 | }, 410 | "autoload": { 411 | "psr-4": { 412 | "Psr\\Log\\": "src" 413 | } 414 | }, 415 | "notification-url": "https://packagist.org/downloads/", 416 | "license": [ 417 | "MIT" 418 | ], 419 | "authors": [ 420 | { 421 | "name": "PHP-FIG", 422 | "homepage": "https://www.php-fig.org/" 423 | } 424 | ], 425 | "description": "Common interface for logging libraries", 426 | "homepage": "https://github.com/php-fig/log", 427 | "keywords": [ 428 | "log", 429 | "psr", 430 | "psr-3" 431 | ], 432 | "support": { 433 | "source": "https://github.com/php-fig/log/tree/3.0.2" 434 | }, 435 | "time": "2024-09-11T13:17:53+00:00" 436 | } 437 | ], 438 | "aliases": [], 439 | "minimum-stability": "stable", 440 | "stability-flags": { 441 | "nextcloud/coding-standard": 20, 442 | "nextcloud/ocp": 20, 443 | "psalm/phar": 20 444 | }, 445 | "prefer-stable": false, 446 | "prefer-lowest": false, 447 | "platform": { 448 | "php": ">=8.0 <8.5" 449 | }, 450 | "platform-dev": {}, 451 | "plugin-api-version": "2.6.0" 452 | } 453 | -------------------------------------------------------------------------------- /img/app-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /img/app.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /krankerl.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | before_cmds = [ 3 | "composer install --no-dev", 4 | "npm install --deps", 5 | "npm run build", 6 | "l10n/2json.sh", 7 | ] 8 | after_cmds = [ 9 | "rm l10n/*.json", 10 | ] 11 | -------------------------------------------------------------------------------- /l10n/2json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in l10n/*.js 3 | do 4 | echo $i → ${i}on 5 | grep -vE '^\s+/|^$' $i|sed -zE 's/OC.L10N.register\(\s*"twofactor_email",\s+\{/{"generated_–_use_xx.js_instead!":"","translations":{/'|sed -zE 's/,\s+\},\s+""\);/\n},"pluralForm":""}/'| jq -c > ${i}on 6 | done 7 | -------------------------------------------------------------------------------- /l10n/de.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "twofactor_email", 3 | { 4 | // ADDITIONAL strings to be localized in appinfo/info.xml 5 | 6 | // lib/Provider/Email.php 7 | "Email" : "E-Mail", 8 | "Send a code to your email address" : "Sende einen Code an deine E-Mail-Adresse", 9 | 10 | // lib/Service/Email.php 11 | "Login attempt for %s" : "Anmeldeversuch für %s", 12 | "Your two-factor authentication code is: %s" : "Dein Zwei-Faktor Authentifizierungscode lautet: %s", 13 | "If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!" : "Gib diesen Code auf %s ein, falls du dich anmelden wolltest. Falls du das nicht warst kennt jemand deine E-Mail-Adresse oder deinen Benutzernamen – und dein Passwort!", 14 | 15 | // src/components/GatewaySettings.vue 16 | "You need to set an email address in 'Personal info' first." : "Du musst zuerst eine E-Mail-Adresse in 'Persönliche Informationen' hinterlegen.", 17 | 18 | "Could not send a verification code via email. An Admin must set this up first." : "Prüfcode konnte nicht per E-Mail versendet werden. Ein Administrator muss dies zuerst einrichten.", 19 | "Enable Two-Factor Authentication via Email" : "Zwei-Faktor Authentifizierung per E-Mail einschalten", 20 | 21 | "The entered code does not match that sent to {emailAddress}." : "Der eigegebene Code unterscheidet sich von dem an {emailAddress} gesendeten.", 22 | "A code has been sent to {emailAddress}." : "Ein Code wurde an {emailAddress} gesendet.", 23 | "Verify code" : "Code bestätigen", 24 | "Cancel activation" : "Einschalten abbrechen", 25 | 26 | "Two-Factor Authentication via Email is enabled. Codes are sent to {emailAddress}." : "Zwei-Faktor Authentifizierung per E-Mail ist eingeschaltet. Codes werden an {emailAddress} gesendet.", 27 | "Disable Two-Factor Authentication via Email" : "Zwei-Faktor Authentifizierung per E-Mail ausschalten", 28 | 29 | // templates/error.php 30 | "Error while sending the email. Please try again later or ask your administrator." : "Fehler beim Versenden der E-Mail. Bitte probiere es später nochmal oder frage deinen Administrator.", 31 | 32 | // templates/challenge.php 33 | "A code has been sent to your email address." : "Ein Code wurde an deine E-Mail-Adresse gesendet", 34 | "Authentication code" : "Authentifizierungscode", 35 | "Submit" : "Übermitteln", 36 | }, 37 | ""); 38 | -------------------------------------------------------------------------------- /l10n/fr.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "twofactor_email", 3 | { 4 | // ADDITIONAL strings to be localized in appinfo/info.xml 5 | 6 | // lib/Provider/Email.php 7 | "Email" : "Email", 8 | "Send a code to your email address" : "Code envoyé à votre adresse mail", 9 | 10 | // lib/Service/Email.php 11 | "Login attempt for %s" : "Tentative de connexion pour %s", 12 | "Your two-factor authentication code is: %s" : "Votre code d'authentification est %s", 13 | "If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!" : "Si vous êtes à l'origine de cette tentative de connexion, veuillez entrer ce code pour %s, si vous n'êtes pas à l'origine, une personne a connaissance de votre adresse et de votre mot de passe, nous vous conseillons de les modifier !", 14 | 15 | // src/components/GatewaySettings.vue 16 | "You need to set an email address in 'Personal info' first." : "Vous devez définir votre adresse mail dans 'Info personnelle' en premier.", 17 | 18 | "Could not send a verification code via email. An Admin must set this up first." : "Impossible d'envoyer l'email de vérification. L'administrateur doit d'abord configurer celui-ci.", 19 | "Enable Two-Factor Authentication via Email" : "Activer la double authentification par email", 20 | 21 | "The entered code does not match that sent to {emailAddress}." : "Le code que vous avez entré ne correspond pas au code fournis à l'adresse {emailAddress}.", 22 | "A code has been sent to {emailAddress}." : "Un code a été envoyé à {emailAddress}.", 23 | "Verify code" : "Code de vérification", 24 | "Cancel activation" : "Annuler la connexion", 25 | 26 | "Two-Factor Authentication via Email is enabled. Codes are sent to {emailAddress}." : "La double authentification par email a été activée. Le code a été envoyé à {emailAddress}.", 27 | "Disable Two-Factor Authentication via Email" : "Désactiver la double authentification par email", 28 | 29 | // templates/error.php 30 | "Error while sending the email. Please try again later or ask your administrator." : "Erreur lors de l'envoie de l'email. Veuillez rééssayer plus tard ou veuillez contacter votre administrateur.", 31 | 32 | // templates/challenge.php 33 | "A code has been sent to your email address." : "Un code a été envoyé à votre adresse mail.", 34 | "Authentication code" : "Code d'authentification", 35 | "Submit" : "Valider", 36 | }, 37 | ""); 38 | -------------------------------------------------------------------------------- /l10n/pt_BR.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "twofactor_email", 3 | { 4 | // ADDITIONAL strings to be localized in appinfo/info.xml 5 | 6 | // lib/Provider/Email.php 7 | "Email" : "E-Mail", 8 | "Send a code to your email address" : "Envie um código para seu endereço de e-mail", 9 | 10 | // lib/Service/Email.php 11 | "Login attempt for %s" : "Tentativa de login para %s", 12 | "Your two-factor authentication code is: %s" : "Seu código de autenticação de dois fatores é: %s", 13 | "If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!" : "Se você tentou fazer o login, por favor, digite este código em %s. Se você não tentou, alguém tentou e sabe o seu login e a sua senha!", 14 | 15 | // src/components/GatewaySettings.vue 16 | "You need to set an email address in 'Personal info' first." : "Você precisa definir primeiro o seu e-mail em 'Informações pessoais'", 17 | 18 | "Could not send a verification code via email. An Admin must set this up first." : "Não foi possível enviar um código de verificação por e-mail. As configurações iniciais ainda precisam ser realizadas pelo administrador.", 19 | "Enable Two-Factor Authentication via Email" : "Habilitar autenticação de dois fatores via e-mail", 20 | 21 | "The entered code does not match that sent to {emailAddress}." : "O código inserido não corresponde ao enviado para {emailAddress}.", 22 | "A code has been sent to {emailAddress}." : "Um código foi enviado para {emailAddress}.", 23 | "Verify code" : "Verificar o código", 24 | "Cancel activation" : "Cancelar ativação", 25 | 26 | "Two-Factor Authentication via Email is enabled. Codes are sent to {emailAddress}." : "A autenticação de dois fatores via e-mail está habilitada. Os códigos serão enviados para {emailAddress}.", 27 | "Disable Two-Factor Authentication via Email" : "Desabilitar a autenticação de dois fatores via e-mail", 28 | 29 | // templates/error.php 30 | "Error while sending the email. Please try again later or ask your administrator." : "Erro ao enviar o e-mail. Por favor, tente novamente mais tarde ou entre em contato com o seu administrador", 31 | 32 | // templates/challenge.php 33 | "A code has been sent to your email address." : "Um código foi enviado para o seu e-mail.", 34 | "Authentication code" : "Código de autenticação", 35 | "Submit" : "Submeter", 36 | }, 37 | ""); 38 | -------------------------------------------------------------------------------- /l10n/ru.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "twofactor_email", 3 | { 4 | // ADDITIONAL strings to be localized in appinfo/info.xml 5 | 6 | // lib/Provider/Email.php 7 | "Email" : "Электронная почта", 8 | "Send a code to your email address" : "Отправить код на ваш электронный адрес", 9 | 10 | // lib/Service/Email.php 11 | "Login attempt for %s" : "Попытка входа для %s", 12 | "Your two-factor authentication code is: %s" : "Ваш код двухфакторной аутентификации: %s", 13 | "If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!" : "Если вы пытались войти, введите этот код в %s. Если вы этого не делали, это значит что кто-то другой попытался выполнить вход и знает ваш адрес электронной почты или имя пользователя, а также ваш пароль!", 14 | 15 | // src/components/GatewaySettings.vue 16 | "You need to set an email address in 'Personal info' first." : "Сначала вам нужно установить адрес электронной почты в разделе «Личная информация».", 17 | 18 | "Could not send a verification code via email. An Admin must set this up first." : "Не удалось отправить код подтверждения по электронной почте. Для начала администратор должен настроить сервис двухфакторной аутентификации.", 19 | "Enable Two-Factor Authentication via Email" : "Включить двухфакторную аутентификацию по электронной почте", 20 | 21 | "The entered code does not match that sent to {emailAddress}." : "Введенный код не совпадает с отправленным на {emailAddress}.", 22 | "A code has been sent to {emailAddress}." : "Код подтверждения был отправлен на {emailAddress}.", 23 | "Verify code" : "Подтвердить код", 24 | "Cancel activation" : "Отменить активацию", 25 | 26 | "Two-Factor Authentication via Email is enabled. Codes are sent to {emailAddress}." : "Двухэтапная аутентификация по электронной почте включена. Коды подтверждения будут отправлены на {emailAddress}.", 27 | "Disable Two-Factor Authentication via Email" : "Отключить двухфакторную аутентификацию по электронной почте", 28 | 29 | // templates/error.php 30 | "Error while sending the email. Please try again later or ask your administrator." : "Ошибка при отправке письма. Повторите попытку позже или обратитесь к администратору.", 31 | 32 | // templates/challenge.php 33 | "A code has been sent to your email address." : "Код был отправлен на ваш адрес электронной почты.", 34 | "Authentication code" : "Код аутентификации", 35 | "Submit" : "Подтвердить", 36 | }, 37 | ""); 38 | -------------------------------------------------------------------------------- /l10n/tr.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "twofactor_email", 3 | { 4 | // ADDITIONAL strings to be localized in appinfo/info.xml 5 | 6 | // lib/Provider/Email.php 7 | "Email" : "E-posta", 8 | "Send a code to your email address" : "E-posta adresinize bir kod gönderin", 9 | 10 | // lib/Service/Email.php 11 | "Login attempt for %s" : "%s için oturum açma girişimi", 12 | "Your two-factor authentication code is: %s" : "İki aşamalı kimlik doğrulama kodunuz: %s", 13 | "If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!" : "Oturum açmayı denediyseniz, %s üzerinde bu kodu girin. Siz yapmadıysanız başka biri denedi ve e-posta adresinizi veya kullanıcı adınızı – ve parolanızı biliyor!", 14 | 15 | // src/components/GatewaySettings.vue 16 | "You need to set an email address in 'Personal info' first." : "Önce 'Kişisel bilgiler' bölümünde bir e-posta adresi ayarlamanız gerekir.", 17 | 18 | "Could not send a verification code via email. An Admin must set this up first." : "E-posta yoluyla bir doğrulama kodu gönderilemedi. Bu, önce bir Yönetici tarafından ayarlanmalıdır.", 19 | "Enable Two-Factor Authentication via Email" : "E-posta ile İki Adımlı Kimlik Doğrulamayı Etkinleştir", 20 | 21 | "The entered code does not match that sent to {emailAddress}." : "Girilen kod {emailAddress} adresine gönderilenle eşleşmiyor.", 22 | "A code has been sent to {emailAddress}." : "{emailAddress} adresine bir kod gönderildi.", 23 | "Verify code" : "Kodu doğrula", 24 | "Cancel activation" : "Etkinleştirmeyi iptal et", 25 | 26 | "Two-Factor Authentication via Email is enabled. Codes are sent to {emailAddress}." : "E-posta ile İki Adımlı Kimlik Doğrulama etkinleştirildi. Kodlar {emailAddress} adresine gönderiliyor.", 27 | "Disable Two-Factor Authentication via Email" : "E-posta ile İki Adımlı Kimlik Doğrulamayı Devre Dışı Bırak", 28 | 29 | // templates/error.php 30 | "Error while sending the email. Please try again later or ask your administrator." : "E-posta gönderilirken hata oluştu. Lütfen daha sonra tekrar deneyin veya yöneticinize danışın.", 31 | 32 | // templates/challenge.php 33 | "A code has been sent to your email address." : "E-posta adresinize bir kod gönderildi.", 34 | "Authentication code" : "Kimlik doğrulama kodu", 35 | "Submit" : "Gönder", 36 | }, 37 | ""); 38 | -------------------------------------------------------------------------------- /lib/AppInfo/Application.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * @author Roeland Jago Douma 8 | * 9 | * @license GNU AGPL version 3 or any later version 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Affero General Public License as 13 | * published by the Free Software Foundation, either version 3 of the 14 | * License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Affero General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Affero General Public License 22 | * along with this program. If not, see . 23 | * 24 | */ 25 | 26 | namespace OCA\TwoFactorEmail\AppInfo; 27 | 28 | use OCP\AppFramework\App; 29 | 30 | class Application extends App { 31 | public const APP_NAME = 'twofactor_email'; 32 | 33 | public function __construct(array $urlParams = []) { 34 | parent::__construct(self::APP_NAME, $urlParams); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/Controller/SettingsController.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * @author Roeland Jago Douma 8 | * 9 | * @license GNU AGPL version 3 or any later version 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Affero General Public License as 13 | * published by the Free Software Foundation, either version 3 of the 14 | * License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Affero General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Affero General Public License 22 | * along with this program. If not, see . 23 | * 24 | */ 25 | 26 | namespace OCA\TwoFactorEmail\Controller; 27 | 28 | use OCA\TwoFactorEmail\AppInfo\Application; 29 | use OCA\TwoFactorEmail\Exception\TransmissionException; 30 | use OCA\TwoFactorEmail\Exception\VerificationException; 31 | use OCA\TwoFactorEmail\Service\SetupService; 32 | use OCP\AppFramework\Controller; 33 | use OCP\AppFramework\Http; 34 | use OCP\AppFramework\Http\JSONResponse; 35 | use OCP\IRequest; 36 | use OCP\IUserSession; 37 | 38 | class SettingsController extends Controller { 39 | 40 | public function __construct( 41 | IRequest $request, 42 | private IUserSession $userSession, 43 | private SetupService $setupService, 44 | ) { 45 | parent::__construct(Application::APP_NAME, $request); 46 | } 47 | 48 | /** 49 | * @NoAdminRequired 50 | */ 51 | public function startVerification(): JSONResponse { 52 | $user = $this->userSession->getUser(); 53 | 54 | if ($user === null) { 55 | return new JSONResponse([], Http::STATUS_BAD_REQUEST); 56 | } 57 | 58 | try { 59 | $state = $this->setupService->startSetup($user); 60 | } catch (TransmissionException $ex) { 61 | return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); 62 | } 63 | 64 | return new JSONResponse($this->setupService->getState($user)); 65 | } 66 | 67 | /** 68 | * @NoAdminRequired 69 | * 70 | * @param string $verificationCode 71 | * 72 | */ 73 | public function finishVerification(string $verificationCode): JSONResponse { 74 | $user = $this->userSession->getUser(); 75 | 76 | if ($user === null) { 77 | return new JSONResponse([], Http::STATUS_BAD_REQUEST); 78 | } 79 | 80 | try { 81 | $this->setupService->finishSetup($user, $verificationCode); 82 | } catch (VerificationException $ex) { 83 | return new JSONResponse([], Http::STATUS_BAD_REQUEST); 84 | } 85 | 86 | return new JSONResponse([]); 87 | } 88 | 89 | /** 90 | * @NoAdminRequired 91 | */ 92 | public function revokeVerification(): JSONResponse { 93 | $user = $this->userSession->getUser(); 94 | 95 | if ($user === null) { 96 | return new JSONResponse([], Http::STATUS_BAD_REQUEST); 97 | } 98 | 99 | return new JSONResponse($this->setupService->disable($user)); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lib/Exception/TransmissionException.php: -------------------------------------------------------------------------------- 1 | l10n->t('Email'); 55 | } 56 | 57 | /** 58 | * Get the description for selecting the 2FA provider 59 | */ 60 | public function getDescription(): string { 61 | return $this->l10n->t('Send a code to your email address'); 62 | } 63 | 64 | private function getSecret(): string { 65 | if ($this->session->exists($this->getSessionKey())) { 66 | return $this->session->get($this->getSessionKey()); 67 | } 68 | 69 | $secret = $this->secureRandom->generate(6, ISecureRandom::CHAR_DIGITS); 70 | $this->session->set($this->getSessionKey(), $secret); 71 | 72 | return $secret; 73 | } 74 | 75 | /** 76 | * Get the template for rending the 2FA provider view 77 | */ 78 | public function getTemplate(IUser $user): Template { 79 | $secret = $this->getSecret(); 80 | 81 | try { 82 | $this->emailService->send($user, $secret); 83 | } catch (\Exception $ex) { 84 | return new Template('twofactor_email', 'error'); 85 | } 86 | 87 | $tmpl = new Template('twofactor_email', 'challenge'); 88 | $tmpl->assign('emailAddress', $user->getEMailAddress()); 89 | 90 | return $tmpl; 91 | } 92 | 93 | /** 94 | * Verify the given challenge 95 | */ 96 | public function verifyChallenge(IUser $user, string $challenge): bool { 97 | $valid = $this->session->exists($this->getSessionKey()) 98 | && $this->session->get($this->getSessionKey()) === $challenge; 99 | 100 | if ($valid) { 101 | $this->session->remove($this->getSessionKey()); 102 | } 103 | 104 | return $valid; 105 | } 106 | 107 | /** 108 | * Decides whether 2FA is enabled for the given user 109 | */ 110 | public function isTwoFactorAuthEnabledForUser(IUser $user): bool { 111 | return $this->stateStorage->get($user)->getState() === self::STATE_ENABLED; 112 | } 113 | 114 | public function getPersonalSettings(IUser $user): IPersonalProviderSettings { 115 | return new PersonalSettings($this->initialStateService, $this->stateStorage->get($user), $user->getEMailAddress() !== null); 116 | } 117 | 118 | public function getLightIcon(): String { 119 | return $this->urlGenerator->imagePath(Application::APP_NAME, 'app.svg'); 120 | } 121 | 122 | public function getDarkIcon(): String { 123 | return $this->urlGenerator->imagePath(Application::APP_NAME, 'app-dark.svg'); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /lib/Provider/State.php: -------------------------------------------------------------------------------- 1 | user, 37 | Email::STATE_ENABLED, 38 | $this->authenticationCode 39 | ); 40 | } 41 | 42 | public function getUser(): IUser { 43 | return $this->user; 44 | } 45 | 46 | public function getState(): int { 47 | return $this->state; 48 | } 49 | 50 | public function getVerificationCode(): ?string { 51 | return $this->authenticationCode; 52 | } 53 | 54 | public function jsonSerialize(): array { 55 | if ($this->user->getEMailAddress() === null) { 56 | return [ 57 | 'state' => $this->state, 58 | 'emailAddress' => '', 59 | ]; 60 | } 61 | 62 | return [ 63 | 'state' => $this->state, 64 | 'emailAddress' => $this->user->getEMailAddress(), 65 | ]; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/Service/Email.php: -------------------------------------------------------------------------------- 1 | logger->debug('Sending email message to ' . $user->getEMailAddress() . ', code: ' . $authenticationCode); 26 | 27 | $template = $this->mailer->createEMailTemplate('twofactor_email.send'); 28 | $user_at_cloud = $user->getDisplayName() . " @ " . $this->themingDefaults->getName(); 29 | $template->setSubject($this->l10n->t('Login attempt for %s', [$user_at_cloud])); 30 | $template->addHeader(); 31 | $template->addHeading($this->l10n->t('Your two-factor authentication code is: %s', [$authenticationCode])); 32 | $template->addBodyText($this->l10n->t('If you tried to login, please enter that code on %s. If you did not, somebody else did and knows your your email address or username – and your password!', [$this->themingDefaults->getName()])); 33 | $template->addFooter(); 34 | 35 | $message = $this->mailer->createMessage(); 36 | $message->setTo([ $user->getEMailAddress() => $user->getDisplayName() ]); 37 | $message->useTemplate($template); 38 | 39 | $this->mailer->send($message); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/Service/SetupService.php: -------------------------------------------------------------------------------- 1 | stateStorage->get($user); 30 | } 31 | 32 | /** 33 | * Send out confirmation message and save current authentication code in user settings 34 | */ 35 | public function startSetup(IUser $user): State { 36 | $authenticationCode = $this->random->generate(6, ISecureRandom::CHAR_DIGITS); 37 | 38 | try { 39 | $this->emailService->send($user, $authenticationCode); 40 | } catch (Exception $ex) { 41 | throw new TransmissionException('Could not send verification code', 0, $ex); 42 | } 43 | 44 | return $this->stateStorage->persist( 45 | State::verifying($user, $authenticationCode) 46 | ); 47 | } 48 | 49 | public function finishSetup(IUser $user, string $authenticationCode): State { 50 | $state = $this->stateStorage->get($user); 51 | 52 | if (is_null($state->getVerificationCode())) { 53 | throw new VerificationException('no verification code set'); 54 | } 55 | 56 | if ($state->getVerificationCode() !== $authenticationCode) { 57 | throw new VerificationException('verification code mismatch'); 58 | } 59 | 60 | $this->providerRegistry->enableProviderFor($this->emailProvider, $user); 61 | 62 | return $this->stateStorage->persist( 63 | $state->verify() 64 | ); 65 | } 66 | 67 | public function disable(IUser $user): State { 68 | $this->providerRegistry->enableProviderFor($this->emailProvider, $user); 69 | $this->providerRegistry->disableProviderFor($this->emailProvider, $user); 70 | 71 | return $this->stateStorage->persist( 72 | State::disabled($user) 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/Service/StateStorage.php: -------------------------------------------------------------------------------- 1 | config->getUserValue($user->getUID(), Application::APP_NAME, $key, $default); 23 | } 24 | 25 | private function setUserValue(IUser $user, string $key, ?string $value): void { 26 | $this->config->setUserValue($user->getUID(), Application::APP_NAME, $key, $value); 27 | } 28 | 29 | private function deleteUserValue(IUser $user, string $key): void { 30 | $this->config->deleteUserValue($user->getUID(), Application::APP_NAME, $key); 31 | } 32 | 33 | public function get(IUser $user): State { 34 | $isVerified = $this->getUserValue($user, 'verified', 'false') === 'true'; 35 | $authenticationCode = $this->getUserValue($user, 'authentication_code'); 36 | 37 | if ($isVerified) { 38 | $state = EmailProvider::STATE_ENABLED; 39 | } elseif ($authenticationCode !== '') { 40 | $state = EmailProvider::STATE_VERIFYING; 41 | } else { 42 | $state = EmailProvider::STATE_DISABLED; 43 | } 44 | 45 | return new State( 46 | $user, 47 | $state, 48 | $authenticationCode 49 | ); 50 | } 51 | 52 | public function persist(State $state): State { 53 | switch ($state->getState()) { 54 | case EmailProvider::STATE_DISABLED: 55 | $this->deleteUserValue( 56 | $state->getUser(), 57 | 'verified' 58 | ); 59 | $this->deleteUserValue( 60 | $state->getUser(), 61 | 'authentication_code' 62 | ); 63 | 64 | break; 65 | case EmailProvider::STATE_VERIFYING: 66 | $this->setUserValue( 67 | $state->getUser(), 68 | 'authentication_code', 69 | $state->getVerificationCode() 70 | ); 71 | $this->setUserValue( 72 | $state->getUser(), 73 | 'verified', 74 | 'false' 75 | ); 76 | 77 | break; 78 | case EmailProvider::STATE_ENABLED: 79 | $this->setUserValue( 80 | $state->getUser(), 81 | 'authentication_code', 82 | $state->getVerificationCode() 83 | ); 84 | $this->setUserValue( 85 | $state->getUser(), 86 | 'verified', 87 | 'true' 88 | ); 89 | 90 | break; 91 | default: 92 | throw new Exception('Invalid provider state'); 93 | } 94 | 95 | return $state; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/Settings/PersonalSettings.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * @author Roeland Jago Douma 8 | * 9 | * @license GNU AGPL version 3 or any later version 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Affero General Public License as 13 | * published by the Free Software Foundation, either version 3 of the 14 | * License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Affero General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Affero General Public License 22 | * along with this program. If not, see . 23 | * 24 | */ 25 | 26 | namespace OCA\TwoFactorEmail\Settings; 27 | 28 | use OCA\TwoFactorEmail\AppInfo\Application; 29 | use OCA\TwoFactorEmail\Provider\State; 30 | use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings; 31 | use OCP\IInitialStateService; 32 | use OCP\Template; 33 | 34 | class PersonalSettings implements IPersonalProviderSettings { 35 | 36 | public function __construct( 37 | private IInitialStateService $initialStateService, 38 | private State $state, 39 | private bool $available, 40 | ) { 41 | } 42 | 43 | /** 44 | * @return Template 45 | * 46 | * @since 15.0.0 47 | */ 48 | public function getBody(): Template { 49 | $this->initialStateService->provideInitialState(Application::APP_NAME, 'available', $this->available); 50 | $this->initialStateService->provideInitialState(Application::APP_NAME, 'state', $this->state); 51 | return new Template('twofactor_email', 'personal_settings'); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "twofactor_email", 3 | "description": "Two-Factor Email Provider", 4 | "author": [ 5 | { 6 | "name": "Olav Seyfarth (current maintainer)", 7 | "email": "olav@seyfarth.de" 8 | } 9 | ], 10 | "contributors": [ 11 | { 12 | "name": "Roeland Jago Douma (original author)" 13 | } 14 | ], 15 | "license": "AGPL-3.0-or-later", 16 | "main": "index.js", 17 | "directories": { 18 | "lib": "lib", 19 | "test": "tests" 20 | }, 21 | "scripts": { 22 | "build": "./node_modules/webpack-cli/bin/cli.js --config src/webpack.prod.config.js", 23 | "dev": "./node_modules/webpack-cli/bin/cli.js --config src/webpack.dev.config.js --watch", 24 | "test": "echo \"Error: no test specified\" && exit 1", 25 | "lint": "eslint --ext .js,.vue src", 26 | "lint:fix": "eslint --ext .js,.vue src --fix", 27 | "stylelint": "stylelint src", 28 | "stylelint:fix": "stylelint src --fix" 29 | }, 30 | "dependencies": { 31 | "nextcloud-server": "latest", 32 | "@nextcloud/axios": "latest", 33 | "@nextcloud/initial-state": "latest", 34 | "vue": "v2-latest" 35 | }, 36 | "devDependencies": { 37 | "@babel/core": "latest", 38 | "@babel/eslint-parser": "latest", 39 | "@babel/preset-env": "latest", 40 | "@nextcloud/eslint-config": "latest", 41 | "@nextcloud/eslint-plugin": "latest", 42 | "@typescript-eslint/eslint-plugin": "latest", 43 | "@typescript-eslint/parser": "latest", 44 | "css-loader": "latest", 45 | "eslint": "latest", 46 | "eslint-config-standard": "latest", 47 | "eslint-plugin-import": "latest", 48 | "eslint-plugin-jsdoc": "latest", 49 | "eslint-plugin-node": "latest", 50 | "eslint-plugin-promise": "latest", 51 | "eslint-plugin-vue": "latest", 52 | "eslint-webpack-plugin": "latest", 53 | "stylelint": "latest", 54 | "stylelint-config-recommended-scss": "latest", 55 | "stylelint-scss": "latest", 56 | "stylelint-webpack-plugin": "latest", 57 | "vue-loader": "legacy", 58 | "vue-template-compiler": "latest", 59 | "webpack": "latest", 60 | "webpack-cli": "latest", 61 | "webpack-merge": "latest" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /psalm.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /screenshots/challenge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nursoda/twofactor_email/75122ccd5d771f2f442190c52dca8d48668f44cf/screenshots/challenge.png -------------------------------------------------------------------------------- /screenshots/select-auth_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nursoda/twofactor_email/75122ccd5d771f2f442190c52dca8d48668f44cf/screenshots/select-auth_thumb.png -------------------------------------------------------------------------------- /screenshots/settings-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nursoda/twofactor_email/75122ccd5d771f2f442190c52dca8d48668f44cf/screenshots/settings-after.png -------------------------------------------------------------------------------- /screenshots/settings-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nursoda/twofactor_email/75122ccd5d771f2f442190c52dca8d48668f44cf/screenshots/settings-before.png -------------------------------------------------------------------------------- /src/components/GatewaySettings.vue: -------------------------------------------------------------------------------- 1 | 49 | 50 | 135 | 136 | 141 | -------------------------------------------------------------------------------- /src/components/L10n.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 26 | -------------------------------------------------------------------------------- /src/init.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @copyright Copyright (c) 2018 Roeland Jago Douma 3 | * 4 | * @author Roeland Jago Douma 5 | * 6 | * @license AGPL-3.0-or-later 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | import Vue from 'vue' 24 | import EmailSettings from './views/EmailSettings.vue' 25 | 26 | new Vue({ 27 | render: h => h(EmailSettings), 28 | }).$mount('#twofactor-email') 29 | -------------------------------------------------------------------------------- /src/service/registration.js: -------------------------------------------------------------------------------- 1 | import Axios from '@nextcloud/axios' 2 | import { generateUrl } from 'nextcloud-server/dist/router.js' 3 | 4 | /** 5 | * Starts the verification. 6 | * 7 | * @return {Promise} 8 | */ 9 | export function startVerification() { 10 | const url = generateUrl('/apps/twofactor_email/settings/enable') 11 | 12 | return Axios.post(url).then(resp => resp.data) 13 | } 14 | 15 | /** 16 | * Compares the entered code with the generated/saved one. 17 | * 18 | * @param {string} code the user entered 19 | * @return {Promise} 20 | */ 21 | export function tryVerification(code) { 22 | const url = generateUrl('/apps/twofactor_email/settings/validate') 23 | 24 | return Axios.post(url, { 25 | verificationCode: code, 26 | }).then(resp => resp.data) 27 | } 28 | 29 | /** 30 | * Disables the Two-Factor method for this user. 31 | * 32 | * @return {Promise} 33 | */ 34 | export function disable() { 35 | const url = generateUrl('/apps/twofactor_email/settings/disable') 36 | 37 | return Axios.delete(url).then(resp => resp.data) 38 | } 39 | -------------------------------------------------------------------------------- /src/views/EmailSettings.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 26 | 27 | 36 | -------------------------------------------------------------------------------- /src/webpack.base.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const { VueLoaderPlugin } = require('vue-loader') 3 | 4 | module.exports = { 5 | entry: './src/init.js', 6 | output: { 7 | filename: '2fa-email.js', 8 | path: path.resolve(__dirname, '../js'), 9 | }, 10 | resolve: { 11 | modules: [path.resolve(__dirname), 'node_modules'], 12 | fallback: { 13 | fs: false, 14 | }, 15 | }, 16 | module: { 17 | rules: [ 18 | { 19 | test: /\.vue$/, 20 | loader: 'vue-loader', 21 | options: { 22 | loaders: {}, 23 | }, 24 | }, 25 | { 26 | test: /\.css$/, 27 | use: [ 28 | { 29 | loader: 'vue-style-loader', 30 | }, 31 | { 32 | loader: 'css-loader', 33 | options: { 34 | modules: true, 35 | }, 36 | }, 37 | ], 38 | }, 39 | ], 40 | }, 41 | plugins: [ 42 | new VueLoaderPlugin(), 43 | ], 44 | } 45 | -------------------------------------------------------------------------------- /src/webpack.dev.config.js: -------------------------------------------------------------------------------- 1 | const { merge } = require('webpack-merge') 2 | const baseConfig = require('./webpack.base.config.js') 3 | 4 | module.exports = merge(baseConfig, { 5 | devtool: 'inline-source-map', 6 | mode: 'development', 7 | }) 8 | -------------------------------------------------------------------------------- /src/webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | const { merge } = require('webpack-merge') 3 | const baseConfig = require('./webpack.base.config.js') 4 | 5 | module.exports = merge(baseConfig, { 6 | plugins: [ 7 | new webpack.DefinePlugin({ 8 | 'process.env': { 9 | NODE_ENV: JSON.stringify('production'), 10 | }, 11 | }), 12 | new webpack.optimize.AggressiveMergingPlugin(), // Merge chunks 13 | ], 14 | mode: 'production', 15 | devtool: 'source-map', 16 | }) 17 | -------------------------------------------------------------------------------- /templates/challenge.php: -------------------------------------------------------------------------------- 1 |

t('A code has been sent to your email address.')) ?>

2 |
3 | 4 | 7 |
8 | -------------------------------------------------------------------------------- /templates/error.php: -------------------------------------------------------------------------------- 1 |
2 | t('Error while sending the email. Please try again later or ask the administrator.')); ?> 3 |
4 | -------------------------------------------------------------------------------- /templates/personal_settings.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | -------------------------------------------------------------------------------- /tests/psalm-baseline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Template 6 | Template 7 | Template 8 | 9 | 10 | 11 | 12 | [ $user->getEMailAddress() => $user->getDisplayName() ] 13 | 14 | 15 | 16 | 17 | Template 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------