Stuck using SAML with google - coldfusion

I have been tasked with finding out how to integrate SAML single log in with an existing application. And Im finding it MORE than difficult to find answers past setting up an Identity Provider.
For a first pass attempt I have set up Google G-suite SAML app...
I have the information ( entityId, ACS url, IDP Metadata xml )
I have set up a URL for a test application, and I'm trying to find ANY information on what to write... I can find NO code samples...Of course I can find other service providers "implementation" samples, but that doesn't help me, as my app will be the service provider.
ANY Help on this, how to code a 'log in' button for google SAML App.
Here is the code Im trying - it's in coldfusion, but you'll get the gist - response is status code 400
<cfsavecontent variable="req">
<cfoutput>
<samlp:AuthnRequest
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="!!!!!GENERATEDUNIQUEREQUESTID!!!!!"
Version="2.0"
ProviderName="SP test"
IssueInstant="2014-07-16T23:52:45Z"
Destination="https://CLIENTSITE.MYDOMAIN.com/samlLogin"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
AssertionConsumerServiceURL="https://saml.MYDOMAIN.com/acs/process">
<saml:Issuer>https://saml.MYDOMAIN.com/sp/entityId</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" AllowCreate="true"/>
<samlp:RequestedAuthnContext Comparison="exact">
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
</cfoutput>
</cfsavecontent>
<html>
<head>
</head>
<body>
<cfoutput>
<div>
<form id="login-google" action="https://accounts.google.com/o/saml2/idp?idpid=!!!!!IDCODE!!!!!" method="post">
<input type="hidden" name="SAMLResponse" value="#toBase64( trim( req ), 'utf-8' )#" />
<input type="submit" value="Login" />
</form>
</div>
</cfoutput>
</body>
</html>

Related

how can i send a small data like a url to the new tab that a chrome extension opens?

So i have the following code that upon clicking the button opens the localhost main html file where flask app.py is running on flask server
$("#startbutton").click(function(){
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function
(tabs) {
urlPresent = tabs[0].url;
//var myWindow = window.open("http://localhost:3000/", "_blank");
//myWindow.document.write("<h1> urlPresent</h1> "+urlPresent);
window.open('http://localhost:3000/', '_blank');
});
flask server is running at http://localhost:3000/
Now i have url of the active website, is there any way i can send this urlPresent variable to the new tab that opens from this button #startbutton to the html file on server whose code is
<form action="{{url_for('scrap')}}" method="post" id="theform">
<b>
Enter Review:
<input type="text" name="reviewfield" value="" id="inputfield"
/></b>
<br />
<br />
<input type="submit" value="Scrap and Predict" />
</form>
</center>
and set it to the value of the form input type text.
PS: I have the webpage that is automatically populated with the url (with the help of chrome extension - i know it would be simpler to just copy the url but my professor wants me to automate it) which is then scrapped and feeded into the classifier and then the results are returned.

How to write jest test cases for navigation in react

I am new to Jest test cases writing, Trying to write the test case for checking navigation in an react application.
Currently I have written test case which works like below:
I have Login page which is having register link on it, which redirects user to the Register page. So what I am checking is
1. Loading the login page
2. Triggered Register link click event
3. So user moved to the Register page
but I am not able to check if the Register page is loaded or not? Is there any way to check the snapshot of the "Register" page and link in URL.
I have used jest, enzyme and react-test-render as shown in below code.
Login Page Html
<React.Fragment>
<BodyContainer noDrawer fullSpan>
<Grid container spacing={0} className={classes.gridContainer}>
<Grid item xs={12} md={6} lg={7} className="login--form">
<div className="login--form--container">
<img src={LogoPurple} alt="ABL" className="onboarding-logo" />
<h3>Welcome back! Please login to your account.</h3>
{error ? <p>{error}</p> : null}
<Field name="email" component={renderTextField} label="Email" style={styles.formField}/>
<Field name="password" component={renderTextField} label="Password" style={styles.formField} />
<Field name="rememberMe" component={renderCheckbox} label="Remember Me" />
<div className="has-spacing">
<Button variant="raised" size="large" color="primary" className="extraLarge" type="submit" onClick={this.handleSubmit}>
Login
</Button>
</div>
<Link to="forgot-password">Forgot Password</Link>
<p className="need-account">
Need an account?
<Link to="/register">
<strong> Sign up</strong>
</p>
</Link>
<LegalLinks />
</div>
</Grid>
</Grid>
</BodyContainer>
</React.Fragment>
In above code register is the link used to navigate.
thanks in advance...

Why doesn't this XSS work?

Possibly simple solution, but I can't understand why my attempt to run this alert script on my welcome page via XSS input on the index page doesn't work.
I have a simple index.htm page with a form:
<!DOCTYPE html>
<html>
<body>
<form method="post" action="welcome.php">
Name: <input type="text" name="name">
<input type="submit">
</form>
</body>
</html>
And the welcome.php file:
<!DOCTYPE html>
<html>
<body>
<h3> Welcome <?php echo $_POST['name']; ?> </h3>
</body>
</html>
As a visitor to the index.php page, in the Name field I attempted to enter:
<script>alert("pwned")</script>
This has nothing to deal with PHP itself, as most browsers has XSS auditor which will try to protect the user from know XSS attacks
Running your example would result in:
The XSS Auditor refused to execute a script in 'http://localhost:9093/welcome.php' because its source code was found within the request. The auditor was enabled as the server did not send an 'X-XSS-Protection' header.
For more information, you can check this question

Coldfusion - Simple HTML Parsing

We currently have some articles that get posted onto our site. they can appear with the following types of html
<p>this is an article<br>
<img src="someimage">
</p>
<p>this is an article<br>
<img src="someimage">
</p>
<p>this is an article<br>
<img src="someimage">
</p>
<p>this is an article<br>
<img src="someimage">
</p>
or
<p><img src="someimage">
this is an article<br>
</p>
<p>this is an article<br>
<img src="someimage">
</p>
<p><img src="someimage">
this is an article<br>
</p>
Some other html tags may be inside this sometimes, I cant get my head around how to scrape the page using coldfusion to achieve this
Esentially what i need to do is grab hold of the first paragraph text and image and be able to arrange it.
Is this possible using Coldfusion 8 ? Would anyone be able to point me in the direction on how to learn this ?
100% definitely possible!
Now, don't be put off by what I'm going to suggest, it's actually very easy to get going with this.
Download a library called jSoup...it's sole purpose is for scraping contents from the DOM in a web page:
http://jsoup.org/
You would then use this Java class by doing something like:
<!--- Get the page. --->
<cfhttp method="get" url="http://example.com/" resolveurl="true" useragent="#cgi.http_user_agent#" result="myPage" timeout="10" charset="utf-8">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
</cfhttp>
<!--- Load up jSoup and parse the document with it. --->
<cfset jsoup = createObject("java", "org.jsoup.Jsoup") />
<cfset document = jsoup.parse(myPage.filecontent) />
<!--- Search the parsed document for the contents of the TITLE tag. --->
<cfset title = document.select("title").first() />
<!--- Let's see what we got. --->
<cfdump var="#title#" />
This example is pretty simple but it can show you just how easy it is to work with. Scraping images and whatever else would be fairly easy if you check out the docs on jSoup.
There are some good examples on this page, where you can use CSS style selectors:
http://jsoup.org/cookbook/extracting-data/selector-syntax
Try to avoid using Regex for this task - believe me, I've tried and it's an absolute can of worms!
Hope this helps.
Mikey.

Get authorize.net CIM hosted form token as a response

I'm using CIM hosted page in my web-site page like,
<form method="post" action="https://secure.authorize.net/profile/manage"
id="formAuthorizeNetPage" style="display:none;">
<input type="hidden" name="Token"
value="pfGaUNntoTxZYeqqYDjGCQ4qyCHcsXGXLJ2i7MPCEiH6CH5n5qKqcl8EBiTClxu01B
SeH5eZg7LVUVVzw5kJKVMitQ3pyMB5UZCduMWd6Ku9aT2gyFm69EKMGfyWPmI4p+Bb4TJf2F0
7rInSrn2MWlM6f2xd7aRu1XBn0WXoPxK1j9FMGX2CNCoCBp3cOXB7"
/>
</form>
My confusion is how to get Token value here.
pass this XML as a request,
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<getHostedProfilePageRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">"<merchantAuthentication>".
<name>loginname</name>
<transactionKey>transactionkey </transactionKey>
</merchantAuthentication>
<customerProfileId>cim_id</customerProfileId>
<hostedProfileSettings>
</hostedProfileSettings>
</getHostedProfilePageRequest>
and check its response, where you can find token value for particular CIM user profile :)