Documentation ¶
Index ¶
- Constants
- func AuthHeader(apiURL string, params ParamsSort, httpMethod string, contentType string, ...) (string, error)
- func Decode(payload string) ([]byte, error)
- func DecryptJWE(pemPrivaKey *rsa.PrivateKey, compactJWE string) (string, error)
- func DecryptPrivateKey(secureCertLocation string, passphrase string) (*rsa.PrivateKey, error)
- func GenerateAuthorizationHeader(apiURL string, params ParamsSort, httpMethod string, contentType string, ...) (string, error)
- func GenerateBaseString(httpMethod string, apiURL string, appId string, params ParamsSort, ...) string
- func GenerateRandomHex(count int) (string, error)
- func GenerateSignature(privateKey *rsa.PrivateKey, baseString string) (string, error)
- func MyInfoConnector(appConfig AppConfig) error
- func SendRequest(request *http.Request) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- func VerifyJWS(publicCert string, accessToken string) ([]byte, error)
- type AppConfig
- func (appConfig AppConfig) CallPersonAPI(sub, accessToken, txnNo string, privateKey *rsa.PrivateKey) ([]byte, error)
- func (appConfig AppConfig) CallTokenAPI(authCode string, privateKey *rsa.PrivateKey, state string) ([]byte, error)
- func (appConfig AppConfig) CheckConfig() error
- func (appConfig AppConfig) GetAccessToken(authCode string, state string) ([]byte, error)
- func (appConfig AppConfig) GetMyInfoPersonData(authCode, state string) ([]byte, error)
- func (appConfig AppConfig) GetPersonData(accessToken, txnNo string) ([]byte, error)
- func (appConfig AppConfig) GetPersonDataWithKey(accessToken, txnNo string, privateKey *rsa.PrivateKey) ([]byte, error)
- type Params
- type ParamsSort
Constants ¶
View Source
const ( ERROR string = "error" OK string = "OK" INVALID_TOKEN string = "invalid token" UINFIN_NOT_FOUND string = "uinfin not found" PERSON_DATA_NOT_FOUND string = "person data not found" INVALID_DATA_OR_SIGNATURE string = "invalid data or signature for person data" ERROR_CONFIGURATION_PUBLIC_CERT_NOT_FOUND string = "public cert not found" ERROR_CONFIGURATION_CLIENT_ID_NOT_FOUND string = "client id not found" ERROR_CONFIGURATION_CLIENT_SECRET_NOT_FOUND string = "client secret not found" ERROR_CONFIGURATION_REDIRECT_URL_NOT_FOUND string = "redirect URL not found" ERROR_CONFIGURATION_CLIENT_SECURE_CERT_NOT_FOUND string = "client secure cert not found" ERROR_CONFIGURATION_CLIENT_SECURE_CERT_PASSPHRASE_NOT_FOUND string = "client passphrase not found" ERROR_CONFIGURATION_ENVIRONMENT_NOT_FOUND string = "environment not found" ERROR_CONFIGURATION_TOKEN_URL_NOT_FOUND string = "token URL not found" ERROR_CONFIGURATION_PERSON_URL_NOT_FOUND string = "person URL not found" ERROR_CONFIGURATION_ATTRIBUTES_NOT_FOUND string = "attributes not found" ERROR_CONFIGURATION_PROXY_TOKEN_URL_NOT_FOUND string = "proxy token URL not found" ERROR_CONFIGURATION_PROXY_PERSON_URL_NOT_FOUND string = "proxy person URL not found" ERROR_UNKNOWN_AUTH_LEVEL string = "unknown auth level" ERROR_UNKNOWN_NOT_INIT string = "configurations not initialized" HTTP_METHOD_GET string = http.MethodGet HTTP_METHOD_POST string = http.MethodPost CONTENT_TYPE string = "application/x-www-form-urlencoded" FAILED_TO_PARSE_RSA_PRIVATE_KEY string = "unable to parse rsa private key" SINPASS_TEST_ENVIRONMENT string = "TEST" SINPASS_SANDBOX_ENVIRONMENT string = "SANDBOX" SINPASS_PRODUCTION_ENVIRONMENT string = "PRODUCTION" APP_ID string = "app_id" NONCE string = "nonce" SIGNATURE_METHOD string = "signature_method" RS256 string = "RS256" TIMESTAMP string = "timestamp" PARAM_REDIRECT_URL string = "redirect_uri" PARAM_CLIENT_ID string = "client_id" PARAM_CLIENT_SECRET string = "client_secret" PARAM_CODE string = "code" PARAM_GRANT_TYPE string = "grant_type" AUTHORIZATION_CODE string = "authorization_code" PARAM_STATE string = "state" AUTHORIZATION string = "Authorization" CACHE_CONTROL string = "Cache-Control" NO_CACHE string = "no-cache" CONTENT string = "Content-Type" UNEXPECTED_STATUS_CODE string = "unexpected status code found:" PARAM_ATTRIBUTES string = "attributes" PARAM_TXNNO string = "txnNo" BEARER string = "Bearer" )
Variables ¶
This section is empty.
Functions ¶
func AuthHeader ¶
func AuthHeader(apiURL string, params ParamsSort, httpMethod string, contentType string, environment string, appId string, privateKey *rsa.PrivateKey, clientSecret string) (string, error)
*
- AuthHeader *
- This method removes the duplication use of environment based condition for generating auth header. *
- Returns fully generated auth Header as string.
func Decode ¶
*
- Decode *
- This method helps to decode the payload data into normal form. *
- Returns normalized(decoded) []byte.
func DecryptJWE ¶
func DecryptJWE(pemPrivaKey *rsa.PrivateKey, compactJWE string) (string, error)
*
- Decypt JWE *
- This method takes in a JSON Web Encrypted string and will decrypt it using the
- private key. This is required to decrypt the data from Person API *
- Returns decrypted data
func DecryptPrivateKey ¶
func DecryptPrivateKey(secureCertLocation string, passphrase string) (*rsa.PrivateKey, error)
*
Get Private Key *
This methods will decrypt P12 Certificate and retrieve the Private key with the passphrase
Returns private key from p12
func GenerateAuthorizationHeader ¶
func GenerateAuthorizationHeader(apiURL string, params ParamsSort, httpMethod string, contentType string, environment string, appId string, privateKey *rsa.PrivateKey, clientSecret string) (string, error)
*
- Generate Authorization Header *
- This method helps to generate the authorization header and sign it
- using the private key. This is required to be used for both Token and Person API *
- Returns Signed Header
func GenerateBaseString ¶
func GenerateRandomHex ¶
*
- Generate Random Hex *
- This method helps to generate unique Transaction ID(txnNo) *
- Returns random hex(txnNo)
func GenerateSignature ¶
func GenerateSignature(privateKey *rsa.PrivateKey, baseString string) (string, error)
func MyInfoConnector ¶
This function validate and initialize all the config variables
func SendRequest ¶
*
- Send Request *
- This function is a wrapper to make https call *
- Returns the response of the hit api
Types ¶
type AppConfig ¶
type AppConfig struct { MYINFO_SIGNATURE_CERT_PUBIC_CERT string CLIENT_ID string CLIENT_SECRET string CLIENT_SECURE_CERT string CLIENT_SECURE_CERT_PASSPHRASE string REDIRECT_URL string PURPOSE string ATTRIBUTES string ENVIRONMENT string TOKEN_URL string PERSON_URL string // Proxy parameters (OPTIONAL) USE_PROXY string // Indicate whether proxy url is used. i.e Y or N PROXY_TOKEN_URL string // Configure your proxy url here, if any PROXY_PERSON_URL string // Configure your proxy url here, if anys }
App Config structure
func (AppConfig) CallPersonAPI ¶
func (appConfig AppConfig) CallPersonAPI(sub, accessToken, txnNo string, privateKey *rsa.PrivateKey) ([]byte, error)
*
- Call Person API *
- This method will generate the Authorization Header and
- and call the Person API to get the encrypted Person Data *
- Returns result from calling Person API
func (AppConfig) CallTokenAPI ¶
func (appConfig AppConfig) CallTokenAPI(authCode string, privateKey *rsa.PrivateKey, state string) ([]byte, error)
*
- Call (Access) Token API *
- This method will generate the Authorization Header
- and call the Token API to retrieve access token. *
- Returns the full json response as []byte.
func (AppConfig) CheckConfig ¶
func (AppConfig) GetAccessToken ¶
func (AppConfig) GetMyInfoPersonData ¶
* * Get MyInfo Person Data (MyInfo Token + Person API) * * This method takes in all the required variables, invoke the following APIs. * - Get Access Token (Token API) - to get Access Token by using the Auth Code and State * - Get Person Data (Person API) - to get Person Data by using the Access Token * * Returns the Person Data as []byte (Payload decrypted + Signature validated) *
func (AppConfig) GetPersonData ¶
func (AppConfig) GetPersonDataWithKey ¶
func (appConfig AppConfig) GetPersonDataWithKey(accessToken, txnNo string, privateKey *rsa.PrivateKey) ([]byte, error)
*
- Get Person Data With Key *
- This method will take in the accessToken from Token API and decode it
- to get the sub(eg either uinfin or uuid). It will call the Person API using the token and sub.
- It will verify the Person API data's signature and decrypt the result. *
- Returns decrypted result from calling Person API
type ParamsSort ¶
type ParamsSort []Params
func (ParamsSort) Len ¶
func (slice ParamsSort) Len() int
func (ParamsSort) Less ¶
func (slice ParamsSort) Less(i, j int) bool
func (ParamsSort) Swap ¶
func (slice ParamsSort) Swap(i, j int)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.