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

Connect-vRAServer - Usecase issue where UPN used as Username #233

Closed
Stevio54 opened this issue Jul 10, 2020 · 7 comments · Fixed by #235
Closed

Connect-vRAServer - Usecase issue where UPN used as Username #233

Stevio54 opened this issue Jul 10, 2020 · 7 comments · Fixed by #235
Assignees
Labels
Milestone

Comments

@Stevio54
Copy link
Contributor

The recent update to the Connect-vRAServer commandlet to add advanced authentication login functionality helped me locate a new issue.

If an environment sets the UPN (userPrincipalName) as the userName for vRealize Automation, they will not be able to authenticate. This is because the UPN often takes the form of a domain login (e.g. scarnes@my.local) and so the advanced login is used, by splitting this into its two parts (username = scarnes, and domain = my.local).

However, in that case, the login will fail as the server is expecting it to come through as such: (username=scarnes@my.local, and domain = my.local).

We need to address this login use-case, and my proposal is to add a $Domain parameter to the login, and infer an advanced login when this is provided, or simply use the simple login process.

As an alternative, I also suggest in addition to this to also provide a flag such as "-Advanced" in order to force the use of the advanced login as well. (and in this case, it can infer the domain from the username supplied)

@Stevio54 Stevio54 added the bug label Jul 10, 2020
@Stevio54 Stevio54 self-assigned this Jul 10, 2020
@Stevio54
Copy link
Contributor Author

After some thought, introducing a Domain parameter and supplying a LoginType with a default value of "Simple" and an optional value of "Advanced" may be a cleaner approach

@martin9700
Copy link
Contributor

Maybe even getting more granular in the login type: Simple, DomainUser, UPN, etc. Approach it as someone who's never looked at the code and won't know what "Advanced" means.

@jonathanmedd jonathanmedd added this to the 4.1.0 milestone Jul 20, 2020
@Stevio54
Copy link
Contributor Author

so, I researched a little more into the logins and the types. I don't actually see why we care which login you use.... In either case we are currently not allowing the user of a cspAuthToken as that does not work for the API calls we make. Also, I tested, and when we send login payloads to either place (i.e. /csp/gateway/am/idp/auth/login or /csp/gateway/am/api/login) the payload to send is the same schema:
image

As seen we have the option to send the domain or not. I tried all types of logins on both URL's and all work fine without the need to "infer" a domain after the @ symbol.

{
  "username": "Administrator",
  "password": "REDACTED",
  "domain": "System Domain"
}
{
  "username": "scarnes@kpsc.io",
  "password": "REDACTED"
}
{
  "username": "scarnes",
  "password": "REDACTED",
  "domain": "kpsc.io"
}

Even this

{
  "username": "scarnes@kpsc.io",
  "password": "REDACTED",
  "domain": "kpsc.io"
}

All of the above worked, and the payload we get back is always the same, here is an example (all tokens have expired at this point).

{
    "scope": "openid profile user email",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjE3ODE3NjI3MjMxODg4MjcyMDkwIn0.eyJpc3MiOiJDTj1QcmVsdWRlIElkZW50aXR5IFNlcnZpY2UsT1U9Q01CVSxPPVZNd2FyZSxMPVNvZmlhLFNUPVNvZmlhLEM9QkciLCJpYXQiOjE1OTUyODg2NzIsImV4cCI6MTU5NTMxNzQ3MiwianRpIjoiZTc5NTQxMmItOTY4NC00NGU0LTlmMTUtYWQzZTkzNzJmMzdlIiwiY29udGV4dCI6Ilt7XCJtdGRcIjpcInVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphYzpjbGFzc2VzOlBhc3N3b3JkUHJvdGVjdGVkVHJhbnNwb3J0XCIsXCJpYXRcIjoxNTk1Mjg4NjcyLFwiaWRcIjoxNX1dIiwiYXpwIjoicHJlbHVkZS11c2VyLVNDVEJwSVZ4YkEiLCJzdWIiOiJTeXN0ZW0gRG9tYWluOjk0YjBjNWMzLTRiNzYtNDcxYy1iZTYwLWMzMTc3Nzc0YTA4YSIsImRvbWFpbiI6IlN5c3RlbSBEb21haW4iLCJ1c2VybmFtZSI6IkFkbWluaXN0cnRvciIsInBlcm1zIjpbImNzcDpvcmdfb3duZXIiLCJleHRlcm5hbC9mOGRiZmQ0Zi0yZTJkLTRlZjEtOTdjNS0wNDBiMGU1YmQwZDIvYXV0b21hdGlvbnNlcnZpY2U6Y2xvdWRfYWRtaW4iLCJleHRlcm5hbC9h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X2qsocWfHmebJF1MLOVyJ0rdzsS9PwqVm32HjSGFvrGo_tncNhAd_w",
    "token_type": "Bearer",
    "expires_in": 28799
}

So, my thought is to just reverse the last change to the login, and choose a method to use. The Doc's do call one of the logins "Enhanced" but I fail to see how it is.

What are others thoughts on this?

@Stevio54
Copy link
Contributor Author

One last thought, there is one scenario I forgot to test and that is when the user is set to the SAMAccountName and the username in the payload includes the domain. If that doesn't check out it's back to the drawing board but unfortunately I have some personal errands for the rest of tonight until I can get back at it.

@Stevio54
Copy link
Contributor Author

After further investigation this morning, I found that if the IDM is set to use SAM instead of UPN, it does require a specific syntax to login, so I will continue with my pull request.

@Stevio54
Copy link
Contributor Author

About to link a pull request. Kept this simple and just added a parameter called UserAttribute, which takes (UPN,SAM,sAMAccountName, or userPrincipalName) as values, and defaults to SAM. For more information please take a look at the pull request that is incoming.

@jonathanmedd
Copy link
Contributor

@Stevio54 Nice work on this one, appreciate the thorough effort to test the different scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants