Skip to content

Commit

Permalink
feat: support for learning-only users
Browse files Browse the repository at this point in the history
  • Loading branch information
piejanssens committed Jul 17, 2024
1 parent b4f7d69 commit 433d6e5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ This utility can generate and validate key pairs, generate SAML assertions accep

Features:

- [Generate a new key pair](#generate-a-new-key-pair)
- [Check certificate validity](#check-the-oauth-client-certificates-validity)
- [Generate assertion (and validate)](#generate-via-cli)
- [Run a local web service to generate an assertion and provide access tokens](#run-a-web-service-returning-oauth-access-tokens)
- [Integrate with a Postman OAuth flow to obtain an access token](#usage-with-postman)
- [OAuth 2.0 SAML Assertion Access Token Generator for SAP SuccessFactors HXM Suite](#oauth-20-saml-assertion-access-token-generator-for-sap-successfactors-hxm-suite)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Generate a new key pair](#generate-a-new-key-pair)
- [Create or update the OAuth client in SuccessFactors](#create-or-update-the-oauth-client-in-successfactors)
- [Run a web service returning OAuth access tokens](#run-a-web-service-returning-oauth-access-tokens)
- [Usage with Postman](#usage-with-postman)
- [Generate via CLI](#generate-via-cli)
- [Argument Aliases](#argument-aliases)
- [Check the OAuth client certificate's validity](#check-the-oauth-client-certificates-validity)
- [Learning Only Users](#learning-only-users)
- [Contributing](#contributing)
- [Sponsorship](#sponsorship)

## Prerequisites

Expand Down Expand Up @@ -127,19 +136,20 @@ Token is valid 🎉
#### Argument Aliases
| alias | argument |
| ----- | ------------ |
| -g | --generate |
| -n | --newkeypair |
| -c | --clientId |
| -u | --userId |
| -i | --companyId |
| -h | --hostname |
| -v | --validate |
| -t | --ttl |
| -p | --port |
| -r | --raw |
| -d | --dir |
| alias | argument |
| ----- | -------------- |
| -g | --generate |
| -n | --newkeypair |
| -c | --clientId |
| -u | --userId |
| -i | --companyId |
| -h | --hostname |
| -v | --validate |
| -t | --ttl |
| -p | --port |
| -r | --raw |
| -d | --dir |
| -l | --learningOnly |
### Check the OAuth client certificate's validity
Expand All @@ -148,6 +158,10 @@ $ sf-oauth --validate [--companyId]
notAfter=Mar 6 13:37:03 2032 GMT
```
### Learning Only Users
The SuccessFactors Learning OAuth token server is deprecated. Instead, you can use the SuccessFactors Platform token server to generate OAuth tokens even if the user does not exist in Employee Profile or Employee Central, a so-called learning-only user. For this use-case, use the `-l` or `--learningOnly` argument.
## Contributing
Contributions are more than welcome! Please open an issue or a pull request.
Expand Down
3 changes: 3 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ try {
'--port': Number,
'--raw': Boolean,
'--dir': String,
'--learningOnly': Boolean,
// Aliases
'-g': '--generate',
'-n': '--newkeypair',
Expand All @@ -39,6 +40,7 @@ try {
'-p': '--port',
'-r': '--raw',
'-d': '--dir',
'-l': '--learningOnly'
})
} catch (err) {
switch (err.code) {
Expand Down Expand Up @@ -100,6 +102,7 @@ if (args['--generate']) {
userId,
hostname,
companyId,
!!args['--learningOnly'],
args['--ttl'],
args['--raw']
)
Expand Down
4 changes: 3 additions & 1 deletion src/gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function generate(
sUser,
sHostname,
companyId,
learningOnly,
iTtl = 600,
silent = false
) {
Expand Down Expand Up @@ -53,8 +54,9 @@ function generate(
attributes: {
api_key: sClientId,
use_username: 'false',
external_user: learningOnly ? 'true' : 'false'
},
nameIdentifier: sUser,
nameIdentifier: learningOnly ? `${sUser}#DIV#${companyId}` : sUser,
sessionIndex: crypto.randomUUID(),
recipient: `https://${sHostname}/oauth/token`,
}
Expand Down

0 comments on commit 433d6e5

Please sign in to comment.