Identity Wrapper is a GO component which provides ERPLY Identity Service endpoints for other GO projects.
For example:
- login with credentials
- launch apps
- get JWT
- revoke JWT
- verify JWT.
- etc.
- go 1.12+
import (
"github.com/erply/identity-wrapper/Identity"
)
- host is
https://id-api.erply.com/
- apiWorkers - Default value
1
- maxIdleConnections - Default value
1
- maxConnections - Default value
1
- host is
https://id-api-sb.erply.com/
- apiWorkers - Default value
1
- maxIdleConnections - Default value
1
- maxConnections - Default value
1
Init Identity API
identityAPI := Identity.SetupAPI(host, apiWorkers, maxIdleConnections, maxConnections)
identityAPI.Init()
*Note: apiWorkers, maxIdleConnections, maxConnections
are variadic input parameters.
SetupAPI function can be called like:
//Option 1
identityAPI := Identity.SetupAPI(host)
//Option 2
identityAPI := Identity.SetupAPI(host, apiWorkers)
//Option 3
identityAPI := Identity.SetupAPI(host, apiWorkers, maxIdleConnections)
LoginWithCredentials()
Login to Identity Launchpad with email and password to get JWT. Launchpad JWT is in limited permissions. Check permissions from here https://jwt.io
login, err := identityAPI.LoginWithCredentials("[email protected]", "ExamplePass12")
jwt := login.Result.JWT
companyID := login.Result.DefaultCompanyId
// For other companies IDs you will get if you use func GetUserConfirmedCompanies()
GetApplications()
Get list of all applications.
apps, err := identityAPI.GetApplications(jwt)
GetAccountAccess()
Get list of applications IDs where user account has access. Also, returns company based AccountID to launch apps.
access, err := identityAPI.GetAccountAccess(jwt, companyID)
accountID := access.Result.AccountID
GetUserConfirmedCompanies()
Get list of companies where user has access.
companies, err := identityAPI.GetUserConfirmedCompanies(jwt)
LaunchApp()
Use JWT and and your selected AccountID to launch app and get launchCode.
launch, err := identityAPI.LaunchApp(jwt, accountID)
launchCode := launch.Result.LaunchCode
GetJWT()
Get JWT by launchCode. LunchCode is a hash which expires after 30 sec. Returns JWT with all permissions you have. JWT lives in 24 hours.
getJWT, err := identityAPI.GetJWT(launchCode)
appJWT := getJWT.Result.JWT
GetSessionID()
- GetSessionID by JWT. It returns short session token for Builder applications and Service Engine endpoints.
- Use this token in headers.
JSESSIONID
- if using Builder apps.API_KEY
- if using Service Engine endpoints.
getSession, _ := identityAPI.GetSessionID(appJWT)
sessionID := getSession.Result.Session
RevokeJWT()
It revokes persistence token which makes token unusable. Persistence token is inside of JWT.
revoke, err := identityAPI.RevokeJWT(jwt)
VerifyJWT()
Verify persistence token by sending JWT. Returns (boolean) TRUE if it's valid and FALSE if expired or not exist.
verify, err := identityAPI.VerifyJWT(jwt)
https://apps.erply.com/jwt/pubkey.pem
https://apps-sb.erply.com/jwt/pubkey.pem
- Siim Roostalu - [email protected]