Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
web-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
custom-apps
web-app
Commits
3792d57e
Commit
3792d57e
authored
5 years ago
by
FORESTIER Fabien
Browse files
Options
Downloads
Patches
Plain Diff
Make angular set a x-xsrf-token header on http requests using its csrf feature
parent
f3c55560
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!53
Version 2.3.2
Pipeline
#1764
failed
5 years ago
Stage: build
Stage: deploy
Stage: post-deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/app.module.ts
+4
-1
4 additions, 1 deletion
src/app/app.module.ts
src/app/user/interceptors/auth-interceptor.ts
+0
-23
0 additions, 23 deletions
src/app/user/interceptors/auth-interceptor.ts
src/app/user/user.module.ts
+0
-7
0 additions, 7 deletions
src/app/user/user.module.ts
with
4 additions
and
31 deletions
src/app/app.module.ts
+
4
−
1
View file @
3792d57e
import
{
BrowserModule
}
from
'
@angular/platform-browser
'
;
import
{
BrowserModule
}
from
'
@angular/platform-browser
'
;
import
{
BrowserAnimationsModule
}
from
'
@angular/platform-browser/animations
'
;
import
{
BrowserAnimationsModule
}
from
'
@angular/platform-browser/animations
'
;
import
{
NgModule
,
APP_INITIALIZER
}
from
'
@angular/core
'
;
import
{
NgModule
,
APP_INITIALIZER
}
from
'
@angular/core
'
;
import
{
HttpClientModule
}
from
'
@angular/common/http
'
;
import
{
HttpClientModule
,
HttpClientXsrfModule
}
from
'
@angular/common/http
'
;
import
{
AppComponent
}
from
'
./app.component
'
;
import
{
AppComponent
}
from
'
./app.component
'
;
import
{
AppRoutingModule
}
from
'
./app-routing.module
'
;
import
{
AppRoutingModule
}
from
'
./app-routing.module
'
;
...
@@ -44,6 +44,9 @@ export function initAppConfig(appConfigService: AppConfigService) {
...
@@ -44,6 +44,9 @@ export function initAppConfig(appConfigService: AppConfigService) {
BrowserModule
,
BrowserModule
,
BrowserAnimationsModule
,
BrowserAnimationsModule
,
HttpClientModule
,
HttpClientModule
,
HttpClientXsrfModule
.
withOptions
({
headerName
:
'
x-xsrf-token
'
,
}),
CoreModule
,
CoreModule
,
EditorialisationModule
,
EditorialisationModule
,
UserModule
,
UserModule
,
...
...
This diff is collapsed.
Click to expand it.
src/app/user/interceptors/auth-interceptor.ts
deleted
100644 → 0
+
0
−
23
View file @
f3c55560
import
{
HttpInterceptor
,
HttpRequest
,
HttpHandler
,
HttpEvent
}
from
'
@angular/common/http
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs
'
;
@
Injectable
()
export
class
AuthInterceptor
implements
HttpInterceptor
{
intercept
(
req
:
HttpRequest
<
any
>
,
next
:
HttpHandler
,
):
Observable
<
HttpEvent
<
any
>>
{
const
xsrfToken
=
localStorage
.
getItem
(
'
xsrfToken
'
);
let
request
=
req
;
// && req.url.includes('https://data-intothesky.alpha.grandlyon.com/authentication/api/logout'
if
(
xsrfToken
)
{
request
=
req
.
clone
({
headers
:
req
.
headers
.
set
(
'
x-xsrf-token
'
,
xsrfToken
),
});
}
return
next
.
handle
(
request
);
}
}
This diff is collapsed.
Click to expand it.
src/app/user/user.module.ts
+
0
−
7
View file @
3792d57e
...
@@ -4,8 +4,6 @@ import { UserRoutingModule } from './user-routing.module';
...
@@ -4,8 +4,6 @@ import { UserRoutingModule } from './user-routing.module';
import
{
UserServices
}
from
'
./services
'
;
import
{
UserServices
}
from
'
./services
'
;
import
{
UserComponents
}
from
'
./components
'
;
import
{
UserComponents
}
from
'
./components
'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'
@angular/forms
'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'
@angular/forms
'
;
import
{
HTTP_INTERCEPTORS
}
from
'
@angular/common/http
'
;
import
{
AuthInterceptor
}
from
'
./interceptors/auth-interceptor
'
;
import
{
UserGuards
}
from
'
./guards
'
;
import
{
UserGuards
}
from
'
./guards
'
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
...
@@ -20,11 +18,6 @@ import { SharedModule } from '../shared/shared.module';
...
@@ -20,11 +18,6 @@ import { SharedModule } from '../shared/shared.module';
providers
:
[
providers
:
[
...
UserGuards
,
...
UserGuards
,
...
UserServices
,
...
UserServices
,
{
provide
:
HTTP_INTERCEPTORS
,
useClass
:
AuthInterceptor
,
multi
:
true
,
},
],
],
declarations
:
[...
UserComponents
],
declarations
:
[...
UserComponents
],
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment