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

UA Expert's User Change button doesn't work with the stack #105

Closed
atimin opened this issue Feb 2, 2019 · 1 comment
Closed

UA Expert's User Change button doesn't work with the stack #105

atimin opened this issue Feb 2, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@atimin
Copy link
Member

atimin commented Feb 2, 2019

I have a problem when I try to change a connected user with UA Expert.

Steps:

  1. I implement authentication with the following handler-method:
	void
	Library::authenticationCallback(
			ApplicationAuthenticationContext* applicationAuthenitcationContext)
	{
		Log(Debug, "Event::authenticationCallback")
			.parameter("SessionId", applicationAuthenitcationContext->sessionId_);


		if (applicationAuthenitcationContext->authenticationType_ == OpcUaId_AnonymousIdentityToken_Encoding_DefaultBinary) {
			applicationAuthenitcationContext->statusCode_ = BadIdentityTokenRejected;
		}
		else if (applicationAuthenitcationContext->authenticationType_ == OpcUaId_UserNameIdentityToken_Encoding_DefaultBinary) {

			ExtensibleParameter::SPtr parameter = applicationAuthenitcationContext->parameter_;
			UserNameIdentityToken::SPtr token = parameter->parameter<UserNameIdentityToken>();

			// find user profile
			UserProfile::Map::iterator it;
			it = userMap_.find(token->userName());
			if ( it == userMap_.end()) {
				applicationAuthenitcationContext->statusCode_ = BadUserAccessDenied;
				return;
			}
			UserProfile::SPtr userProfile = it->second;

			// get password
			char* buf;
		    int32_t bufLen;
			token->password((OpcUaByte**)&buf, (OpcUaInt32*)&bufLen);
			if (bufLen <= 0) {
				applicationAuthenitcationContext->statusCode_ = BadUserAccessDenied;
				return;
			}
			std::string password(buf, bufLen);

			// check password
			if (password != userProfile->password_) {
				applicationAuthenitcationContext->statusCode_ = BadUserAccessDenied;
				return;
			}

			applicationAuthenitcationContext->userContext_ = userProfile;
			applicationAuthenitcationContext->statusCode_ = Success;
		}
		else if (applicationAuthenitcationContext->authenticationType_ == OpcUaId_X509IdentityToken_Encoding_DefaultBinary) {
			applicationAuthenitcationContext->statusCode_ = BadIdentityTokenRejected;
		}
		else {
			applicationAuthenitcationContext->statusCode_ = BadIdentityTokenInvalid;
		}
	}
  1. My application have User_RW and User_R users
  2. I connect as User_RW successfully
  3. Click on User Change in context menu of server in UA Expert
  4. Login as User_R
  5. And have Error 'BadIdentityTokenInvalid' was returned during ActivateSession

PS:

Acctually if I try to change user on the same user User_RW, I get the same error.

Logs:

OpcUaServer.log
UAExpertChangeUser.log

@atimin atimin added the bug Something isn't working label Feb 2, 2019
@huebl
Copy link
Contributor

huebl commented Feb 3, 2019

The Activate Session Request in the current implementation can only occur if a Create Session Request has occurred directly before. This behavior needs to be changed.

@huebl huebl closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants