Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce specific connection token: UserName_Basic256Sha256_Token #409

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,24 @@ void UaClient::Connect(const EndpointDescription & endpoint)
Common::Uri uri(session.EndpointUrl);
std::string user = uri.User();
std::string password = uri.Password();
LOG_INFO(Logger, "user: " + user + ", password: "+password + ", host: "+uri.Host()+ ", scheme: "+uri.Scheme());
bool user_identify_token_found = false;
sessionParameters.ClientSignature.Algorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";

for (auto ep : createSessionResponse.Parameters.ServerEndpoints)
{
if (ep.SecurityMode == MessageSecurityMode::None)
{
for (auto token : ep.UserIdentityTokens)
{
LOG_DEBUG(Logger, "check token " + token.PolicyId);
}
for (auto token : ep.UserIdentityTokens)
{
if (token.PolicyId!="UserName_Basic256Sha256_Token")
{
continue;
}
if (user.empty())
{
if (token.TokenType == UserTokenType::Anonymous)
Expand All @@ -289,6 +298,7 @@ void UaClient::Connect(const EndpointDescription & endpoint)
}

user_identify_token_found = true;
LOG_INFO(Logger, "Created user, starting request with policyid: " + token.PolicyId + "\n, securitypolicy: " + token.SecurityPolicyUri);
break;
}
}
Expand Down