I'm trying to set up Authentication and Authorization for my Yesod website according to the book.
However, once I set up my Google OAuth2, I get a timeout:
HttpExceptionRequest Request {
host = "accounts.google.com"
port = 443
secure = True
requestHeaders = [("Content-Type","application/x-www-form-urlencoded")]
path = "/o/oauth2/token"
queryString = ""
method = "POST"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
proxySecureMode = ProxySecureWithConnect
}
ConnectionTimeout
I tried using yesod-auth-oauth2 instead, but I still got a timeout error:
HttpExceptionRequest Request {
host = "www.googleapis.com"
port = 443
secure = True
requestHeaders = [("Content-Type","application/x-www-form-urlencoded"),("Authorization","<REDACTED>"),("User-Agent","hoauth2"),("Accept","application/json")]
path = "/oauth2/v3/token"
queryString = ""
method = "POST"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
proxySecureMode = ProxySecureWithConnect
}
ConnectionTimeout
I have the Google+ API and Contacts API enabled for the web application. I'm running my website locally right now, and have my Authorized redirect URIs as
http://localhost:3000/auth/page/google/callback
http://localhost:3000/auth/page/googleemail2/complete
Turns out for my case, it was due to the IPv6 address of www.googleapis.com being filtered out by Cisco AnyConnect Socket Filter.
For instance, in the connection package, I Debug.Trace.trace'd addrs in the resolve' function to find out that the server was trying to connect initially to the IPv6 address, then the IPv4 one. Connecting to the IPv4 addresses (e.g. using ping or telnet) worked, but the IPv6 address did not, so ultimately it was a firewall issue.
Related
Hi i want send a mail from my linux server my code block/project is working in my local(windows) but i get this error when i run my project in linux.
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
Here is my code block where is my problem? thanks.
string domain = "my.local";
string userName = "info";
string userPass = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("AkXyz2*"));
string host = "mail.mymail.com.tr";
string fromMail = "mymail#mymail.com.tr";
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var smtp = new SmtpClient(host, 587);//port
smtp.EnableSsl = true;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(userName, userPass, domain);
smtp.Credentials = credentials;
smtp.ServicePoint.Expect100Continue = false;
ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;
...
...
smtp.Send(mail);
I have a very basic server written in Python as follows:
import socket
from time import sleep
import requests
c = None #Client socket1
addr = None #Client address1
server_socket1 = socket.socket() #by default it is SOCK_STREAM (TCP) and has porotocal AF_INET (IPv4)
server_socket1.bind(('127.0.0.1',9999)) #server machine's ip and port on which it will send and recieve connections from
server_socket1.listen(2) #We will only accept two connections as of now , one for each client
print("Server started successfully!!!")
print("Waiting for connections...\n\n")
while (((c is None)and(addr is None))):
if((c is None) and (addr is None)):
c,addr = server_socket1.accept()
print("Intrusion detected at address 127.0.0.1:9999 ")
print("Client connected with ip address "+str(addr))
client_ip=str(addr)
while True:
msg = c.recv(4096)
if(msg!=None):
#print(msg)
headers, sep, body = msg.partition(b'\r\n\r\n')
headers = headers.decode('utf-8')
print(headers)
html_body = "<html><body><h1>You are not authorized to acces this Page!</p><br><p>3 more attemps and your ip will be jailed!</p></body></html>"
response_headers = {
'Content-Type': 'text/html; encoding=utf8',
'Content-Length': len(html_body),
'Connection': 'close',
}
response_headers_raw = ''.join('%s: %s\r\n' % (k, v) for k, v in response_headers.items())
response_proto = 'HTTP/1.1'
response_status = '200'
response_status_text = 'OK' # this can be random
# sending all this stuff
r = '%s %s %s\r\n' % (response_proto, response_status, response_status_text)
c.sendall(r.encode())
c.sendall(response_headers_raw.encode())
c.sendall(b'\r\n') # to separate headers from body
c.send(html_body.encode(encoding="utf-8"))
I have then used ngrok to forward my port 9999 on the web. Then I execute the server.
Now, when I connect to the ngrok's provided link via my mobile phone, I get the response from my server, that is a single lined HTML content, as seen in the code itself.
But, the c,addr = socket.accept() should return the IP of the connected client. In my case, I have used my phone to connect to ngrok, which should use my phone's public IP to connect to it, still on my server side, it shows something like this:
Can someone please tell me what am I doing wrong here?
What you are seeing makes perfect sense, as the phone is not directly connected to your server (it can't be, since your server is listening on 127.0.0.1 aka localhost, so it can only accept connections that originate from the same machine).
The phone is connected to ngrok, and then ngrok is connected to your server. So you are seeing the IP that ngrok is connecting to your server from. There is simply no way for your server to get the IP of the phone, unless ngrok includes the phone's IP in the HTTP request it sends to your server, such as in an X-Forwarded-For, X-Original-Forwarded-For, X-Real-IP, etc kind of request header, which are common for proxies to send (but which I don't see in your screenshot, but it is incomplete).
--------- --------- ----------
| phone | <-> | ngrok | <-> | server |
--------- --------- ----------
^ ^
| |
desired IP is here but you are getting IP from here
I am trying to connect to a http server using python but after I send a get request to: https://httpbin.org/ip
I get my normal ip public like if I wasnt using a proxy.
We are going to suppose that my public ip without using proxy is: 10.10.10.10
This is my code:
proxies ={
"http":"http://103.103.175.253:3128"
}
get = requests.get("https://httpbin.org/ip", proxies = proxies)
soup = bs(get.text,'html.parser')
print(soup.prettify())
print(get.status_code, get.reason)
and I get:
{
"origin": "10.10.10.10"
}
200 OK
And I should recieve "origin":"103.103.175.253"
CAN SOMEONE HELP ME PLEASE????
You're connecting to https:// site, but you've only specified http proxy.
You can use http:// protocol, or specify another https proxy. For example:
proxies = {
"http": "http://103.103.175.253:3128",
}
get = requests.get("http://httpbin.org/ip", proxies=proxies) # <-- connect to http://
soup = BeautifulSoup(get.text, "html.parser")
print(soup.prettify())
print(get.status_code, get.reason)
Prints:
{
"origin": "103.103.175.253"
}
200 OK
So I'm using browsermob proxy to login selenium tests to get passed IAP for Google Cloud. But that just gets the user to the site, they still need to login to the site using some firebase login form. IAP has me adding Authorization header through browsermob so you can get to the site itself but the when you try to login through the firebase form you get a 401 error message: "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential..
I thought I could get around this using the whitelist or blacklist feature to just not apply those headers to urls related to the firebase login, but it seems that whitelist and blacklist just return status codes and empty responses for calls that match the regex.
Is there a way to just passthrough certain calls based on the host? Or on the off chance I'm doing something wrong, let me know. Code below:
class ExampleTest(unittest.TestCase):
def setUp(self):
server = Server("env/bin/browsermob-proxy/bin/browsermob-proxy")
server.start()
proxy = server.create_proxy()
bearer_header = {}
bearer_header['Authorization'] = 'Bearer xxxxxxxxexamplexxxxxxxx'
proxy.headers({"Authorization": bearer_header["Authorization"]})
profile = webdriver.FirefoxProfile()
proxy_info = proxy.selenium_proxy()
profile.set_proxy(proxy_info)
proxy.whitelist('.*googleapis.*, .*google.com.*', 200) # This fakes 200 from urls on regex match
# proxy.blacklist('.*googleapis.*', 200) # This fakes 200 from urls if not regex match
self.driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("file-example")
def test_wait(self):
self.driver.get("https://example.com/login/")
time.sleep(3)
def tearDown(self):
self.driver.close()
Figured this out a bit later. There isn't anything built into the BrowserMob proxy/client to do this. But you can achieve it through webdriver's proxy settings.
Chrome
self.chrome_options = webdriver.ChromeOptions()
proxy_address = '{}:{}'.format(server.host, proxy.port)
self.chrome_options.add_argument('--proxy-server=%s' % proxy_address)
no_proxy_string = ''
for item in no_proxy:
no_proxy_string += '*' + item + ';'
self.chrome_options.add_argument('--proxy-bypass-list=%s' % no_proxy_string)
self.desired_capabilities = webdriver.DesiredCapabilities.CHROME
self.desired_capabilities['acceptInsecureCerts'] = True
Firefox
self.desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
proxy_address = '{}:{}'.format(server.host, proxy.port)
self.desired_capabilities['proxy'] = {
'proxyType': "MANUAL",
'httpProxy': proxy_address,
'sslProxy': proxy_address,
'noProxy': ['google.com', 'example.com']
}
self.desired_capabilities['acceptInsecureCerts'] = True
After configuring Kerberos on private server which runs on CentOS 6, I get this error when I run the kinit I get the following response:
kinit: Realm not local to KDC while getting initial credentials
This is the copy of my config file:
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
dns_lookup_realm = true
dns_lookup_kdc = true
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
# rdns = false
default_realm = CENTSERVER01
# default_ccache_name = KEYSTRING:persistent:%{uid}
[realms]
CENTSERVER01 = {
kdc = centserver01:88
admin_server = centserver01:88
}
[domain_realm]
.centserver01 = CENTSERVER01
centserver01 = CENTSERVER01
This error usually means that your Kerberos configuration file, which is by default /etc/krb5.conf, is configured wrong. You'll need to fix that, in order to fix the problem. These errors are usually caught through a simple visual examination of this file. Edit the file according to the sample krb5.conf file on the MIT web site; simply replace the the example.com name with your actual Kerberos realm name and DNS name, keeping note of case sensitivity throughout.