Wowza Community

How to get username for stream

I need a module to validate that a specific user can create a stream with a particular name.

Is there a way to get the username used when authenticating for streaming?

Hi @Gabriel Dogaru

You can find some examples here and here Basically, it’s about extending the AuthenticateUsernamePasswordProviderBase class.

Let me know if you need someone to write this module for you :wink:

I already have that part

My goal is to allow publish only to some of my system’s users to predefined stream names.

So, I am looking for a way to get the username in ModuleBase->onStreamCreate or in a stream listener

If you look at the AuthenticateUsernamePasswordProviderBase, it has a few fields that you could use to store the username, so that you can fetch it later; e.g. you can do this in getPassword:

this.client.getProperties().setProperty("username", username);

And then later you can use

String username = stream.getClient().getProperties.getPropertyStr("username");

By the way, I’d implement IMediaStreamActionNotify2 and do this in the onPublish method rather than in the onStreamCreate.

Oh, remember that stream.getClient() may not work in some cases where you don’t publish over RTMP …

how do I know if the login was successful?

in AuthenticateUsernamePasswordProviderBase I don’t think I have that info