User Login Approach

I am wanting to introduce a programmatic approach to signing in a user using a proprietary login form I created in Perspective. I've set up the functionality to create a new account that ties the user credentials to a User Source that is tied to the default Ignition IdP, and I now want to use a secondary view to sign a user in once they've validated their new account credentials.

I am seeing that the method system.perspective.login([sessionId], [pageId], [forceAuth]) exists that simply redirects users to an embedded login form that performs the action I am wanting to integrate myself, so I essentially want to recreate this same login validation logic using the custom Perspective view I've created that prompts the default IdP with the user credentials entered.

After reviewing the documentation online, I see that the session properties are read only, so I'm hoping there's a method call that accomplishes this. I did find that the Vision method system.security.switchUser(username, password, [event], [hideError]) seems to work as a solution within Vision scoped projects, but I cannot find a compatible Perspective solution for my use case.

For instance, I would make a call like this once a user enters their credentials and presses the login button:

username = str(self.getSibling("username").props.text)
password = str(self.parent.getChild("password-container").getChild("password").props.text)
try:
	if system.security.validateUser(username, password, 'default'):
		userObj = system.user.getUser('default', username)
		try:
			usernameVal  = userObj.get('username')
			passwordVal  = userObj.get('password')
			system.security.switchUser(usernameVal, passwordval, event)
		except Exception as e:
			system.perspective.print('Error collecting user data -> ' + str(e))
	else:
		system.perspective.print("Authentication failed for username: {}".format(username))
except Exception as e:
	system.perspective.print("Authentication block encountered an unhandled exception for user entry: {} -> {}".format(username, str(e)))

Any thoughts on a solution here?

Example Sign In / Sign Up form:


You need to write your own Identity Provider that conforms to the SAML standard. I highly doubt it is possible to use a Perspective view as an IdP.

The amount of work to make that functional when the default Ignition IdP endpoint already consumes a username and password field for authenticating an account seems obstinate.

Is there not some method to simply pass the credentials to the IdP endpoint for validating against the credentials collected from the Perspective view? If not, do you know why this is the case?

It's not a part of the IdP standard, which is not our invention. It's a (set of) accepted standards.

4 Likes