From 7bd843283ddd5a3e4a40277dc1e4d42e31f65c45 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Mon, 9 Nov 2020 15:28:12 +0100 Subject: [PATCH] use django authentication instead of auth tokens. --- Dockerfile | 2 +- src-ui/angular.json | 3 +- src-ui/src/app/app-routing.module.ts | 23 +++--- src-ui/src/app/app.module.ts | 10 +-- .../app-frame/app-frame.component.html | 2 +- .../app-frame/app-frame.component.ts | 8 +-- .../app/components/login/login.component.html | 17 ----- .../components/login/login.component.spec.ts | 25 ------- .../app/components/login/login.component.ts | 34 --------- .../app/services/auth-guard.service.spec.ts | 16 ----- src-ui/src/app/services/auth-guard.service.ts | 20 ------ .../src/app/services/auth.interceptor.spec.ts | 16 ----- src-ui/src/app/services/auth.interceptor.ts | 37 ---------- src-ui/src/app/services/auth.service.spec.ts | 16 ----- src-ui/src/app/services/auth.service.ts | 72 ------------------- .../src/app/services/rest/document.service.ts | 9 ++- src/documents/static/bootstrap.min.css | 7 ++ .../documents/static/signin.css | 30 ++++---- src/documents/templates/index.html | 8 +-- .../templates/registration/logged_out.html | 44 ++++++++++++ .../templates/registration/login.html | 54 ++++++++++++++ src/paperless/auth.py | 20 ++++-- src/paperless/settings.py | 17 ++--- src/paperless/urls.py | 10 +-- 24 files changed, 172 insertions(+), 328 deletions(-) delete mode 100644 src-ui/src/app/components/login/login.component.html delete mode 100644 src-ui/src/app/components/login/login.component.spec.ts delete mode 100644 src-ui/src/app/components/login/login.component.ts delete mode 100644 src-ui/src/app/services/auth-guard.service.spec.ts delete mode 100644 src-ui/src/app/services/auth-guard.service.ts delete mode 100644 src-ui/src/app/services/auth.interceptor.spec.ts delete mode 100644 src-ui/src/app/services/auth.interceptor.ts delete mode 100644 src-ui/src/app/services/auth.service.spec.ts delete mode 100644 src-ui/src/app/services/auth.service.ts create mode 100644 src/documents/static/bootstrap.min.css rename src-ui/src/app/components/login/login.component.css => src/documents/static/signin.css (72%) create mode 100644 src/documents/templates/registration/logged_out.html create mode 100644 src/documents/templates/registration/login.html diff --git a/Dockerfile b/Dockerfile index 015d511d4..05fd430aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,7 @@ COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh # copy app COPY src/ ./src/ -COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ ./src/documents/static/ +COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ ./src/documents/static/frontend/ # add users, setup scripts RUN addgroup --gid 1000 paperless \ diff --git a/src-ui/angular.json b/src-ui/angular.json index 6135ffa91..aca54b8e0 100644 --- a/src-ui/angular.json +++ b/src-ui/angular.json @@ -14,6 +14,7 @@ "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/paperless-ui", + "outputHashing": "none", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -38,7 +39,7 @@ } ], "optimization": true, - "outputHashing": "all", + "outputHashing": "none", "sourceMap": false, "extractCss": true, "namedChunks": false, diff --git a/src-ui/src/app/app-routing.module.ts b/src-ui/src/app/app-routing.module.ts index fde8fd31f..27f0629b4 100644 --- a/src-ui/src/app/app-routing.module.ts +++ b/src-ui/src/app/app-routing.module.ts @@ -4,7 +4,6 @@ import { AppFrameComponent } from './components/app-frame/app-frame.component'; import { DashboardComponent } from './components/dashboard/dashboard.component'; import { DocumentDetailComponent } from './components/document-detail/document-detail.component'; import { DocumentListComponent } from './components/document-list/document-list.component'; -import { LoginComponent } from './components/login/login.component'; import { CorrespondentListComponent } from './components/manage/correspondent-list/correspondent-list.component'; import { DocumentTypeListComponent } from './components/manage/document-type-list/document-type-list.component'; import { LogsComponent } from './components/manage/logs/logs.component'; @@ -12,25 +11,23 @@ import { SettingsComponent } from './components/manage/settings/settings.compone import { TagListComponent } from './components/manage/tag-list/tag-list.component'; import { NotFoundComponent } from './components/not-found/not-found.component'; import { SearchComponent } from './components/search/search.component'; -import { AuthGuardService } from './services/auth-guard.service'; const routes: Routes = [ {path: '', redirectTo: 'dashboard', pathMatch: 'full'}, {path: '', component: AppFrameComponent, children: [ - {path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuardService] }, - {path: 'documents', component: DocumentListComponent, canActivate: [AuthGuardService] }, - {path: 'view/:id', component: DocumentListComponent, canActivate: [AuthGuardService] }, - {path: 'search', component: SearchComponent, canActivate: [AuthGuardService] }, - {path: 'documents/:id', component: DocumentDetailComponent, canActivate: [AuthGuardService] }, + {path: 'dashboard', component: DashboardComponent }, + {path: 'documents', component: DocumentListComponent }, + {path: 'view/:id', component: DocumentListComponent }, + {path: 'search', component: SearchComponent }, + {path: 'documents/:id', component: DocumentDetailComponent }, - {path: 'tags', component: TagListComponent, canActivate: [AuthGuardService] }, - {path: 'documenttypes', component: DocumentTypeListComponent, canActivate: [AuthGuardService] }, - {path: 'correspondents', component: CorrespondentListComponent, canActivate: [AuthGuardService] }, - {path: 'logs', component: LogsComponent, canActivate: [AuthGuardService] }, - {path: 'settings', component: SettingsComponent, canActivate: [AuthGuardService] }, + {path: 'tags', component: TagListComponent }, + {path: 'documenttypes', component: DocumentTypeListComponent }, + {path: 'correspondents', component: CorrespondentListComponent }, + {path: 'logs', component: LogsComponent }, + {path: 'settings', component: SettingsComponent }, ]}, - {path: 'login', component: LoginComponent }, {path: '404', component: NotFoundComponent}, {path: '**', redirectTo: '/404', pathMatch: 'full'} ]; diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index 584b7bc7a..dad57280d 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -12,7 +12,6 @@ import { TagListComponent } from './components/manage/tag-list/tag-list.componen import { DocumentTypeListComponent } from './components/manage/document-type-list/document-type-list.component'; import { LogsComponent } from './components/manage/logs/logs.component'; import { SettingsComponent } from './components/manage/settings/settings.component'; -import { LoginComponent } from './components/login/login.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { DatePipe } from '@angular/common'; import { SafePipe } from './pipes/safe.pipe'; @@ -29,7 +28,6 @@ import { PageHeaderComponent } from './components/common/page-header/page-header import { AppFrameComponent } from './components/app-frame/app-frame.component'; import { ToastsComponent } from './components/common/toasts/toasts.component'; import { FilterEditorComponent } from './components/filter-editor/filter-editor.component'; -import { AuthInterceptor } from './services/auth.interceptor'; import { DocumentCardLargeComponent } from './components/document-list/document-card-large/document-card-large.component'; import { DocumentCardSmallComponent } from './components/document-list/document-card-small/document-card-small.component'; import { NgxFileDropModule } from 'ngx-file-drop'; @@ -53,7 +51,6 @@ import { SortableDirective } from './directives/sortable.directive'; DocumentTypeListComponent, LogsComponent, SettingsComponent, - LoginComponent, SafePipe, NotFoundComponent, CorrespondentEditDialogComponent, @@ -88,12 +85,7 @@ import { SortableDirective } from './directives/sortable.directive'; InfiniteScrollModule ], providers: [ - DatePipe, - { - provide: HTTP_INTERCEPTORS, - useClass: AuthInterceptor, - multi: true - } + DatePipe ], bootstrap: [AppComponent] }) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index ad12a9d43..0b18777ef 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -10,7 +10,7 @@