SFTP equivalent of HTTP URL - url

What can be the URL of SFTP equivalent of the following HTTP URL:
https://myftp.example.com/FolderName/FileName.csv
Also, my SFTP URL will be authenticated with following User Credentials:
Username: User1
Password: Pass1
I tried the following URL:
sftp://User1:Pass1#myftp.example.com:22/FolderName/FileName.csv

Related

Rails 4: CASino integration to several folder in AD using LDAP

I successfully connect the CASino gems to Active Directory by using LDAP. But the problem is, I need to gather the data in AD that located in several folders. How can I do this?
In my cas.yml code I write like this
development:
<<: *defaults
frontend:
sso_name: AUTHENTICATION CENTER
authenticators:
my_company_ldap:
authenticator: LDAP
options:
host: LDAP_HOST
port: 389
base: OU=Users,OU=UserFolder1,OU=Root,DC=company,DC=com
username_attribute: sAMAccountName
encryption: false
admin_user: ADMIN
admin_password: admin
extra_attributes:
email: mail
fullname: displayname
How I can connect to several folders in AD? I tried to write another base: inside it but it only read the newest base, I also tried to customized the value of cas.yml inside the controller, but I need to restart the server to apply the changes. Can I make the base: to read several folders not only UserFolder1?
I found it by myself.
The answer simply just adding a new configuration below that. That makes the config to access several folders in AD.
Here's the example of the implementations
development:
<<: *defaults
frontend:
sso_name: AUTHENTICATION CENTER
authenticators:
my_company_ldap1:
authenticator: LDAP
options:
host: LDAP_HOST
port: 389
base: OU=Users,OU=UserFolder1,OU=Root,DC=company,DC=com
username_attribute: sAMAccountName
encryption: false
admin_user: ADMIN
admin_password: admin
extra_attributes:
email: mail
fullname: displayname
my_company_ldap2:
authenticator: LDAP
options:
host: LDAP_HOST
port: 389
base: OU=Users,OU=UserFolder2,OU=Root,DC=company,DC=com
username_attribute: sAMAccountName
encryption: false
admin_user: ADMIN
admin_password: admin
extra_attributes:
email: mail
fullname: displayname

How to establish connection to the neo4j graph database in javascript with js2neo driver

I get this error when i try to use the connection
WebSocket connection to 'ws://bolt//localhost:7687' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
Downloaded neo4j desktop
started the browser and added a local graph database.
Downloaded the js2neo driver
<script src="js/js2neo.min.js"></script>
connected to the database as per http://js2neo.org/
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
test the content of the database
cx.run("MATCH (n) RETURN *", { onRecord: console.log })
Your host configuration is not good (it's host not url).
So instead of
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
do this :
var cx = js2neo.open({ host: "localhost", user: "neo4j",
password: "1234567890!" })

Invalid client in aqueduct's db_and_auth/wildfire example

I am new to Aqueduct and I am facing a invalid client error whenever I try to make a request to the /auth/token or /auth/code route.
I have already added the OAuth2.0 client and verified the secret is correct.
My request to /auth/token looks like this:
Future main() async {
var http2 = new http.Client();
var clientID = "com.wildfire.mobile";
var clientSecret = "myspecialsecret ";
var body = "username=usr&password=pwd&grant_type=password";
var clientCredentials = new Base64Encoder().convert(
"$clientID:$clientSecret".codeUnits);
var response = await
http.post(
"http://localhost:8081/auth/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
},
body: body);
And when I try logging in in /auth/code with a username in the _user database the server throws a 400:invalid_client
It was indeed a misconfiguration issue. After deleting all my databases, I added a database.yaml file, which I thought was the same as the config.yaml but apparently is not.
The database.yaml looks like this:
username: adan
password: pass
host: localhost
port: 5432
databaseName: wildfire_db
while the config.yaml looks like this:
database:
username: adan
password: pass
host: localhost
port: 5432
databaseName: wildfire_db
I also ran the aqueduct auth and aqueduct db commands without the --connect flag, i.e. using the config files.

Obtain S3 presigned post url with query parameters for a mobile client

I am creating an API for a backend service with Rails 4.
The service needs to upload an image file to an amazon s3 bucket.
I'd like to use a direct upload url, so that the clients manage the uploads to s3 and the server is not kept busy.
Currently I have the following prototypical rails action
def create
filename = params[:filename]
s3_direct_post = S3_BUCKET.presigned_post(key: "offers/#{SecureRandom.uuid}/#{filename}", acl: 'public-read')
s3p = s3_direct_post.fields
url = "#{s3_direct_post.url}/#{filename}?X-Amz-Algorithm=#{s3p['x-amz-algorithm']}&X-Amz-Credential=#{s3p['x-amz-credential']}&X-Amz-Date=#{s3p['x-amz-date']}&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=#{s3p['x-amz-signature']}"
render json: {success: true, url: url}, status: :ok
end
This generates such an url:
https://my-bucket.s3.eu-central-1.amazonaws.com/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MYKEY/20150420/eu-central-1/s3/aws4_request&X-Amz-Date=20150420T162603Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=MYSIGNATURE
Now I try to post the test.png to this url with the following:
curl -v -T test.png "url"
and I get the following error response:
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>MYKEY</AWSAccessKeyId>...
I believe the problem comes from the fact, that the specified X-Amz-SignedHeaders Header is wrong. I am not sure which headers are used by default from the amazon rails sdk gem.
How should I change my url generation, so that a mobile client can just take the url and post a file to it?
Here is a solution:
In config/initializers/aws.rb:
AWS_CREDS = Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
Aws.config.update({
region: 'eu-central-1',
credentials: AWS_CREDS
})
S3 = Aws::S3::Resource.new('eu-central-1')
S3_BUCKET_NAME = ENV['S3_BUCKET_NAME']
S3_BUCKET = S3.bucket(S3_BUCKET_NAME)
In your model/controller/concern/or whatever:
obj = S3_BUCKET.object("offers/#{user.id}/#{self.id}")
url = obj.presigned_url(:put) # obj.presigned_url(:put, acl: 'public-read') #if you want to make the file public
Then to upload you can use a mobile client or curl:
curl -X PUT -T file_to_upload "url from above"
Note that you will have to add the x-amz-acl: public-read header if you used the public-read acl option:
curl -H "x-amz-acl: public-read" -X PUT -T file_to_upload "url from above"

Rails: Omniauth: Github provider doesn't quite work

I recently forked https://github.com/fortuity/rails3-mongoid-omniauth and tried to get login working for different providers. It works for Twitter and Facebook (You can try it out at http://jgodse-omniauth-mongoid.heroku.com/), but I couldn't get it working for Github. The code snapshot is here at github.
My environment looks like this:
$ heroku info
=== jgodse-omniauth-mongoid
Web URL: http://jgodse-omniauth-mongoid.heroku.com/
Git Repo: git#heroku.com:jgodse-omniauth-mongoid.git
Dynos: 1
Workers: 0
Repo size: 7M
Slug size: 5M
Stack: bamboo-mri-1.9.2
Data size: (empty)
Addons: Basic Logging, MongoHQ MongoHQ Free, Shared Database 5MB
Owner: xxxxx#yyy.com
Jay#JAY-PC ~/rapps/rails3-mongoid-omniauth (master)
$ heroku config --long
BUNDLE_WITHOUT => development:test
DATABASE_URL => postgres://xxxxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com/rrretnhwhj
FACEBOOK_APP_ID => xxxxxxxxxxxxxxxxxxxx
FACEBOOK_APP_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITHUB_CLIENT_ID => xxxxxxxxxxxxxxxxxxxxx
GITHUB_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LANG => en_US.UTF-8
MONGOHQ_URL => mongodb://heroku:9xxxxxxxxxxxxxxxx.mongohq.com:27098/app527030
RACK_ENV => production
SHARED_DATABASE_URL => postgres://xxxxxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com/rrretnhwhj
TWITTER_KEY => xxxxxxxxxxxxxxxxxxx
TWITTER_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxx
My github information for "OAuth Application: Jay's Rails3 Mongoid OAuth" is as follows (from my app profile page):
Authorization Token: https://github.com/login/oauth/authorize
Access Token URL: https://github.com/login/oauth/access_token
URL: http://jgodse-omniauth-mongoid.heroku.com/
Callback URL: http://jgodse-omniauth-mongoid.heroku.com/
Client ID: xxxxxxx
Secret: xxxxxxxxxxxxxxxx
The client and secret are set as environment variables in omniauth.rb
The authentication happens, but it redirects to http://jgodse-omniauth-mongoid.heroku.com/?error=redirect_uri_mismatch and I haven't apparently logged in. If I change the Callback URL to http://jgodse-omniauth-mongoid.heroku.com/callback, the application crashes.
What am I missing to get github authentication to work?
I don't fu%^&*g believe this.
I went to github.com where the application secret, key, url, callback is configured and removed the trailing slash from the "Callback URL" and "URL", and it worked.
URL: http://jgodse-omniauth-mongoid.heroku.com
Callback URL: http://jgodse-omniauth-mongoid.heroku.com
This is nuts! Twitter wants the trailing slash on the callback but Github does not. Github and twitter should allow both and then trim it automatically if needed.

Resources