Skip to content

Creating test user service; Add fraud prevention headers#14

Merged
s-patompong merged 10 commits intos-patompong:masterfrom
DarkSide666:master
Apr 7, 2019
Merged

Creating test user service; Add fraud prevention headers#14
s-patompong merged 10 commits intos-patompong:masterfrom
DarkSide666:master

Conversation

@DarkSide666
Copy link
Copy Markdown
Contributor

@DarkSide666 DarkSide666 commented Apr 1, 2019

Features:

  • Adds service for creating test users
  • Adds fraud prevention headers
  • Adds ability to set default headers for all requests (trough Request object or Environment)
  • Adds connection method header values

Fixes:

  • OAuth should use RequestURL constants too

Usage example:

use HMRC\Environment\Environment;
use HMRC\Request\RequestHeader;
use HMRC\Request\RequestHeaderValue;

Environment::getInstance()->setDefaultRequestHeaders([
    RequestHeader::GOV_CLIENT_CONNECTION_METHOD => RequestHeaderValue::WEB_APP_VIA_SERVER,
    RequestHeader::GOV_CLIENT_PUBLIC_IP => $_SERVER['REMOTE_ADDR'],
    RequestHeader::GOV_CLIENT_PUBLIC_PORT => $_SERVER['REMOTE_PORT'],
    RequestHeader::GOV_CLIENT_USER_AGENT => $_SERVER['HTTP_USER_AGENT'],
    RequestHeader::GOV_CLIENT_USER_IDS => 'user='.$this->user->id,
    RequestHeader::GOV_VENDOR_VERSION => 'app='.$this->app->version,
]);

@s-patompong
Copy link
Copy Markdown
Owner

Sorry I was busy and just see this today. I'll need to have a look at the code and will merge if everything is ok.

@DarkSide666
Copy link
Copy Markdown
Contributor Author

No problem. I will use this PR in production after release which will happen this Sunday, so it has to be OK.
Also guy from HMRC few days ago took a look at our test server and approved that all works nicely with them.

@s-patompong s-patompong merged commit 233ca3d into s-patompong:master Apr 7, 2019
@s-patompong
Copy link
Copy Markdown
Owner

I did change $request_headers to $requestHeaders in Environment class. This is for consistency of the project. I'll find a way to add the rule into StypeCI.

@s-patompong s-patompong self-requested a review April 7, 2019 06:10
@s-patompong s-patompong added the enhancement New feature or request label Apr 7, 2019
@s-patompong
Copy link
Copy Markdown
Owner

PR is merged to master and released as v1.2.0 (https://github.com/s-patompong/hmrc-api-php/releases/tag/v1.2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants