Commit 0c77af41 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Initial commit

parents
{
"only": ["./config", "./src"],
"presets": [
"es2015",
"stage-0"
]
}
{
"env": {
"node": true
},
"globals": {
"Promise": true,
"Set": true
},
"parser": "babel-eslint",
"rules": {
"comma-dangle": [2, "always-multiline"],
"max-len": [2, 120, 2],
"no-undef": 2,
"no-unused-expressions": 2,
"no-unused-vars": 2,
"no-use-before-define": [2, "nofunc"],
"quotes": [2, "double", "avoid-escape"],
"semi": [2, "never"],
"strict": 0
}
}
node_modules/
This diff is collapsed.
# AuthAN
> AuthAN is a Node library that allows french deputies, their assistants and the administration members to authenticate using their Assemblée nationale account.
AuthAN is a first step toward the french _Parliament Platform_: It allows the development of applications that use the [Assemblée nationale](http://www.assemblee-nationale.fr/) extranet and require user authentication.
AuthAN is free and open source software, developped by the french Member of Parliament Paula Forteza and its team.
# Usage
See [/src/examples](/src/examples).
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import config from "./global"
export default {
...config,
}
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
username: "TODO",
password: "TODO",
}
\ No newline at end of file
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import config from "./global"
export default {
...config,
// args: [
// // See https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-fails-due-to-sandbox-issues
// "--disable-setuid-sandbox",
// "--no-sandbox",
// ],
}
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require("babel-polyfill") //Must be at the top of the entry point to application.
require("babel-core/register")
require("./src/")
{
"name": "authan",
"version": "1.0.0",
"description": "Authentication library to access French Assemblée nationale services",
"main": "index.js",
"scripts": {
"print_login_cookies": "./node_modules/.bin/babel-node src/examples/print_login_cookies.js"
},
"repository": {
"type": "git",
"url": "https://framagit.org/parlement-ouvert/authan"
},
"keywords": [
"authentication",
"french",
"parliament"
],
"author": "Emmanuel Raviart",
"license": "Apache-2.0",
"dependencies": {
"babel-core": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"puppeteer": "^0.13.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.2",
"eslint": "^4.11.0",
"eslint-plugin-babel": "^4.1.2"
}
}
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Load different configurations (for development, production, etc).
const configFilename = process.env.NODE_ENV || "development"
const config = require("../../config/" + configFilename).default
export default config
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import authan from ".."
import config from "./config"
authan(config).then(cookies => {
console.log(cookies)
process.exit(0)
}).catch(error => {
console.log(error.stack || error)
process.exit(1)
})
\ No newline at end of file
/**
* AuthAN -- Authentication library for French Assemblée nationale
* By: Paula Forteza <paula@retruco.org>
* Emmanuel Raviart <emmanuel@retruco.org>
*
* Copyright (C) 2017 Paula Forteza & Emmanuel Raviart
* https://framagit.org/parlement-ouvert/authan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import puppeteer from "puppeteer"
export default async function login({username, password, ...puppeteerConfig}) {
const browser = await puppeteer.launch(puppeteerConfig)
const page = await browser.newPage()
await page.goto("https://portail.assemblee-nationale.fr")
await page.waitFor("input[name=login]")
await page.type("input[name=login]", username)
await page.type('input[name="password:utf-8:ustring"]', password)
await page.click('input[type="submit"]')
for (let retries = 0; retries < 60; retries ++) {
await page.waitFor(500)
const cookies = await page.cookies()
if (cookies.some(cookie => cookie.name === "IPdiva-WebId")) {
return cookies
}
}
return null
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment