Listening fro 'connect' on all namespaces - flask-socketio

I want to check auth on SocketIO server for all namespaces. How can I listen with #socketio.on('connect') on all namespaces to validate the auth content?
I have tried #socketio.on('connect', namespace='*') but this did not help. Looking at the Namespace class to handle namespaces it does not seems to handle all namespace as well. Any idea?

Try something like this:
#socketio.on('connect', namespace='foo')
#socketio.on('connect', namespace='bar')
#socketio.on('connect', namespace='baz')
def connect():
# common auth here

Related

keycloak starts with a new realm and some client configurations

I try to use keycloak as the authentication service in my design. In my case, when the keycloak starts, I need one more realm besides default master realm. Assuming the new agency is called "demo".
So it means when keycloak starts, it should have two realms (master and demo).
In addtion, in the realm demo, I need to configure the default client "admin-cli" to enable "Full Scope Allowed". Also need to add some buildin mapper to this client.
In this case, I wonder whether I can use something like initialization file which keycloak can load when starting ?
Or I need to use keycloak client APIs to do this operations (e.g., Java keycloak admin client)?
Thanks in advance.
You can try the following:
Create the Realm;
Set all the options that you want;
Go to Manage > Export;
Switch Export groups and roles to ON;
Switch Export clients to ON;
Export.
That will export a .json file with the configurations.
Then you can tested it be deleting your Demo Realm and:
Go to Add Realm;
Chose the .json file that was exported;
Click Create.
Check if the configurations that you have changed are still presented on the Demo Realm, if there are then it means that you can use this file to import the Realm from. Otherwise, for the options that were not persistent you will have to create them via the Admin Rest API.

Using Symfony expression in 3rd party bundle configuration

I am trying to configure HWIOAuth bundle to use dynamic client id. I have a service that can figure out what variable value to use depending on some request conditions.
Here's an expression in my HWI configuration, but can't seem to get it work:
hwi_oauth:
firewall_names:
- main
resource_owners:
auth:
client_id: "#=service('host.configmgr').GetClientIdParameter()"
client_secret: '%client_secret%'
The issue us with #=service('host.configmgr').GetClientIdParameter(). Can that even execute evaluate? The service is properly executes an used by another class somewhere else with success.
The %client_secret% parameter replacement works fine.
For more context, this part of the configuration lives in a dedicated file that is included in config.yml via { resource: hwiconfig.yml }
After some research looks like expressions are only supported for service definitions. This functionality is not supported for configurations outside services like the HWI bundle config.

How to write a HTTP Request in Meteor?

I just find Meteor.methods and Meteor.call in Meteor API, but I want write a post or get methods given to another App invoke. what should I do?
You can use the meteor package http.
Install it by running meteor add http
Here is a link to the docs which has example calls and lists all the arguments you can pass the http call
AN example of a call from the docs:
const result = HTTP.call('GET', 'http://api.twitter.com/xyz', {
params: { user: userId }
});
Look like you want to receive HTTP get and post requests. Am I right?
If yes, look at this package: restivus

how can i check url "\\abc\wof\TY044-12" exist

i 've tried using
string path= "\\abc\wof\TY044-12";
bool exist=System.IO.Directory.Exists(path);
but 'bool' return true on localhost but return false on server side.
Also, i've searched some answers, but it is difficult reconfigure permission of IIS.
can i use FileWebrequest/httpWebRequest command? not understand about this
FileWebRequest request = (FileWebRequest)System.Net.WebRequest.Create("\\abc\wof\TY044-12");
FileWebResponse response = (FileWebResponse)request.GetResponse();
Ihope someone can help me. THANKS!!!
That looks more like a UNC.
To me it seems the appool account on iis which is hosting your application doesn't have permissions to access that UNC folder. Please refer link below to set it:
http://technet.microsoft.com/en-us/library/cc771170(v=ws.10).aspx
The link below says you can access files over the network using pre-registered reserved types like http, https, file, etc.
http://msdn.microsoft.com/en-us/library/bw00b1dc(v=vs.110).aspx
...And if you pass unc paths to the Uri class during construction, you can get the required uri scheme:
var uri = new Uri(#"\\abc\folder\file.jpg");
Console.WriteLine(uri.ToString()); //outputs - file://abc/folder/file.jpg
However the recommended approach is using classes in the System.IO namespace like you originally started out with.

How do I access Request Parameters in Meteor?

I am planning to use Meteor for a realtime logging application for various
My requirement is pretty simple, I will pass a log Message as request Parameter ( POST Or GET) from various application and Meteor need to simply update a collection.
I need to access Request Parameters in Meteor server code and update Mongo collection with the incoming logMessage. I cannot update Mongo Collection directly from existing applications, so please no replies suggesting the same.I want to know how can I do it from Meteor framework and not doing it by adding more packages.
EDIT: Updated to use Iron Router, the successor to Meteor Router.
Install Iron Router and define a server-side route:
Router.map(function () {
this.route('foo', {
where: 'server',
action: function () {
doSomethingWithParams(this.request.query);
}
});
});
So for a request like http://yoursite.com/foo?q=somequery&src=somesource, the variable this.request.query in the function above would be { q: 'somequery', src: 'somesource' } and therefore you can request individual parameters via this.request.query.q and this.request.query.src and the like. I've only tested GET requests, but POST and other request types should work identically; this works as of Meteor 0.7.0.1. Make sure you put this code inside a Meteor.isServer block or in a file in the /server folder in your project.
Original Post:
Use Meteorite to install Meteor Router and define a server-side route:
Meteor.Router.add('/foo', function() {
doSomethingWithParams(this.request.query);
});
So for a request like http://yoursite.com/foo?q=somequery&src=somesource, the variable this.request.query in the function above would be { q: 'somequery', src: 'somesource' } and therefore you can request individual parameters via this.request.query.q and this.request.query.src and the like. I've only tested GET requests, but POST and other request types should work identically; this works as of Meteor 0.6.2.1. Make sure you put this code inside a Meteor.isServer block or in a file in the /server folder in your project.
I know the questioner doesn't want to add packages, but I think that using Meteorite to install Meteor Router seems to me a more future-proof way to implement this as compared to accessing internal undocumented Meteor objects like __meteor_bootstrap__. When the Package API is finalized in a future version of Meteor, the process of installing Meteor Router will become easier (no need for Meteorite) but nothing else is likely to change and your code would probably continue to work without requiring modification.
I found a workaround to add a router to the Meteor application to handle custom requests.
It uses the connect router middleware which is shipped with meteor. No extra dependencies!
Put this before/outside Meteor.startup on the Server. (Coffeescript)
SomeCollection = new Collection("...")
fibers = __meteor_bootstrap__.require("fibers")
connect = __meteor_bootstrap__.require('connect')
app = __meteor_bootstrap__.app
router = connect.middleware.router (route) ->
route.get '/foo', (req, res) ->
Fiber () ->
SomeCollection.insert(...)
.run()
res.writeHead(200)
res.end()
app.use(router)
Use IronRouter, it's so easy:
var path = IronLocation.path();
As things stand, there isn't support for server side routing or specific actions on the server side when URLs are hit. So it's not easy to do what you want. Here are some suggestions.
You can probably achieve what you want by borrowing techniques that are used by the oauth2 package on the auth branch: https://github.com/meteor/meteor/blob/auth/packages/accounts-oauth2-helper/oauth2_server.js#L100-109
However this isn't really supported so I'm not certain it's a good idea.
Your other applications could actually update the collections using DDP. This is probably easier than it sounds.
You could use an intermediate application which accepts POST/GET requests and talks to your meteor server using DDP. This is probably the technically easiest thing to do.
Maybe this one will help you?
http://docs.meteor.com/#meteor_http_post

Resources