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

Enable Avviso SPID n°19 only with public full operator #81

Merged
merged 10 commits into from
May 12, 2021

Conversation

AleDore
Copy link
Contributor

@AleDore AleDore commented May 12, 2021

This PR allows compliance with Avviso SPID n° 19 v4 only for the PublicServicesFullOperator extension.

@pagopa-github-bot
Copy link
Contributor

pagopa-github-bot commented May 12, 2021

Warnings
⚠️ Please include a Pivotal story at the beginning of the PR title (see below).

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

New dependencies added: request-ip.

request-ip

Author: Petar Bojinov

Description: A small node.js module to retrieve the request's IP address

Homepage: https://github.com/pbojinov/request-ip

Createdover 7 years ago
Last Updatedover 2 years ago
LicenseMIT
Maintainers1
Releases21
Direct Dependenciesis_js
Keywordsrequest ip, ip, address, request, proxy, client, header, X-Client-IP, X-Forwarded-For, CF-Connecting-IP, Fastly-Client-IP, True-Client-IP, X-Real-IP, X-Cluster-Client-IP, X-Forwarded, Forwarded-For, connection.remoteAddress, connection.socket.remoteAddress, req.info.remoteAddress, middleware, ipv4 and ipv6
README

request-ip

A tiny Node.js module for retrieving a request's IP address.


Coverage Status

npm version

Installation

npm install request-ip --save

Getting Started

const requestIp = require('request-ip');

// inside middleware handler
const ipMiddleware = function(req, res, next) {
    const clientIp = requestIp.getClientIp(req); 
    next();
};

// on localhost you'll see 127.0.0.1 if you're using IPv4 
// or ::1, ::ffff:127.0.0.1 if you're using IPv6

As Connect Middleware

const requestIp = require('request-ip');
app.use(requestIp.mw())

app.use(function(req, res) {
    const ip = req.clientIp;
    res.end(ip);
});

To see a full working code for the middleware, check out the examples folder.

The connect-middleware also supports retrieving the ip address under a custom attribute name, which also works as a container for any future settings.

How It Works

It looks for specific headers in the request and falls back to some defaults if they do not exist.

The user ip is determined by the following order:

  1. X-Client-IP
  2. X-Forwarded-For (Header may return multiple IP addresses in the format: "client IP, proxy 1 IP, proxy 2 IP", so we take the the first one.)
  3. CF-Connecting-IP (Cloudflare)
  4. Fastly-Client-Ip (Fastly CDN and Firebase hosting header when forwared to a cloud function)
  5. True-Client-Ip (Akamai and Cloudflare)
  6. X-Real-IP (Nginx proxy/FastCGI)
  7. X-Cluster-Client-IP (Rackspace LB, Riverbed Stingray)
  8. X-Forwarded, Forwarded-For and Forwarded (Variations of Bump lodash from 4.17.11 to 4.17.15 #2)
  9. req.connection.remoteAddress
  10. req.socket.remoteAddress
  11. req.connection.socket.remoteAddress
  12. req.info.remoteAddress

If an IP address cannot be found, it will return null.

Samples Use Cases

  • Getting a user's IP for geolocation.

Running the Tests

Make sure you have the necessary dev dependencies needed to run the tests:

npm install

Run the integration tests

npm test

Release Notes

See the wonderful changelog

To easily generate a new changelog, install github-changelog-generator then run npm run changelog.

Contributors

  • Thanks to @osherx for adding the connect-middleware.
  • Thanks to @raunc for adding Squid proxy support.
  • Thanks to @fluxsauce for adding CF-Connecting-IP, True-Client-IP, and ES6 support.
  • Thanks to @vishalvijay for adding Fastly/Firebase hosting support.

License

The MIT License (MIT) - 2018

Generated by 🚫 dangerJS against 8a50188

@AleDore AleDore changed the title Enable Avviso SPID n°19 without public full aggregator Enable Avviso SPID n°19 only with public full operator May 12, 2021
spidTestEnvUrl: "https://spid-testenv2:8088",
spidValidatorUrl: "http://localhost:8080",
// spidValidatorUrl: "http://localhost:8080",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to explain why this line is commented. Later we can fix the spid-saml-check docker image to re-enable that configuration.

src/example.ts Outdated
@@ -72,13 +77,29 @@ const serviceProviderConfig: IServiceProviderConfig = {
],
name: "Required attrs"
},
spidCieUrl: "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth",
spidCieUrl: "https://idserver.servizicie.interno.gov.it:443/idp/shibboleth",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the new test endpoint for CIE metadata https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata
Reference from here

src/example.ts Outdated
@@ -116,7 +137,7 @@ app.use(passport.initialize());
// Create a Proxy to forward local calls to spid validator container
const proxyApp = express();
proxyApp.get("*", (req, res) => {
res.redirect("http://spid-saml-check:8080" + req.path);
res.redirect("localhost:8080" + req.path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works only with an active spid-saml-check

Comment on lines 40 to 44
const CommonExtension = t.partial({
FiscalCode: t.string,
IPACode: t.string,
VATNumber: t.string
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fileds are all required for a Gestore

Suggested change
const CommonExtension = t.partial({
FiscalCode: t.string,
IPACode: t.string,
VATNumber: t.string
});
const CommonExtension = t.interface({
FiscalCode: t.string,
IPACode: t.string,
VATNumber: t.string
});

BurnedMarshal
BurnedMarshal previously approved these changes May 12, 2021
Copy link
Contributor

@BurnedMarshal BurnedMarshal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/example.ts Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

3 participants