Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Auth Headers to PUT Request #115

Open
dagrooms52 opened this issue Jan 24, 2019 · 1 comment
Open

Add Auth Headers to PUT Request #115

dagrooms52 opened this issue Jan 24, 2019 · 1 comment

Comments

@dagrooms52
Copy link

Versions
Node: 10.15.0
OS: win32 x64
Angular: 7.1.4
"adal-angular4": "^4.0.9",

Expected Behavior
Auth headers are added to PUT request
User can specify authentication for HTTP Verbs against configured Authenticated Routes

Actual Behavior
Auth headers are not added to PUT request
User cannot specify authentication for HTTP Verbs against configured Authenticated Routes

Description
I am trying to authenticate only PUT requests against an API route in my Angular 7 application. I have not found a way to configure the adal-angular4 service to send auth headers solely for the PUT verb against this route. It seems that the following configuration is only capable of describing authentication for GET operations against the URI:

endpoints: {
      '{myBaseUrl}/api/github/projects': '{myADGUID}'
    }

When monitoring the PUT request in the Chrome debugger, I see no auth headers added to the request.

Accept: application/json, text/plain, */*
Content-Type: application/json
Origin: myWebsite
Referer: myWebsite
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

Is there a way to specify just PUT verb in the config, or to turn auth on for all verbs against the route?

@dubcdr
Copy link

dubcdr commented Apr 2, 2019

You can do something like this:

@Injectable()
export class CustomAdalInterceptor extends AdalInterceptor {
  constructor(private adalService: AdalService) { super(adalService); }

  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    if (req.method === 'PUT') {
      super.intercept(req, next)
    } else {
      next.handle(req);
    }
  }
}

This will pass the request through the adal interceptor only if its a put request.

You then need to add this interceptor to your providers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants