Documentation ¶
Overview ¶
This is a simple client for the Medidata MAuth Authentication Protocol. It can be used to access Platform Services within the Medidata Clinical Cloud.
MAuth Protocol ¶
The MAuth protocol provides a fault-tolerant, service-to-service authentication scheme for Medidata and third-party applications that use web services to communicate. The Authentication Service and integrity algorithm is based on digital signatures encrypted and decrypted with a private/public key pair.
The Authentication Service has two responsibilities. It provides message integrity and provenance validation by verifying a message sender's signature; its other task is to manage public keys. Each public key is associated with an application and is used to authenticate message signatures. The private key corresponding to the public key in the Authentication Service is stored by the application making a signed request; the request is encrypted with this private key. The Authentication Service has no knowledge of the application's private key, only its public key.
Examples ¶
There are code examples with the methods defined in the core library.
There are two code samples in the examples directory which can be used as a reference
Index ¶
- Constants
- func GetVersion() string
- func MakeAuthenticationHeaders(mauthApp *MAuthApp, signed_string string, seconds_since_epoch int64) map[string]string
- func MakeAuthenticationHeadersV2(mauthApp *MAuthApp, signed_string string, seconds_since_epoch int64) map[string]string
- func MakeSignatureString(mauthApp *MAuthApp, method string, url string, body string, epoch int64) string
- func MakeSignatureStringV2(mauthApp *MAuthApp, method string, url string, body string, epoch int64) string
- func SignString(mauthApp *MAuthApp, stringToSign string) (s string, err error)
- func SignStringV2(mauthApp *MAuthApp, stringToSign string) (s string, err error)
- type MAuthApp
- type MAuthClient
- func (mauthClient *MAuthClient) Delete(targetURL string) (response *http.Response, err error)
- func (mauthClient *MAuthClient) Get(targetURL string) (response *http.Response, err error)
- func (mauthClient *MAuthClient) Post(targetURL string, data string) (response *http.Response, err error)
- func (mauthClient *MAuthClient) Put(targetURL string, data string) (response *http.Response, err error)
- func (client *MAuthClient) SetHeader(headerName, headerValue string)
- type MAuthOptions
Examples ¶
Constants ¶
const VersionString = "1.0.3"
VersionString is the version of this client
Variables ¶
This section is empty.
Functions ¶
func MakeAuthenticationHeaders ¶
func MakeAuthenticationHeaders(mauthApp *MAuthApp, signed_string string, seconds_since_epoch int64) map[string]string
MakeAuthenticationHeaders generates the formatted headers as a map for insertion into the request headers.
func MakeAuthenticationHeadersV2 ¶
func MakeAuthenticationHeadersV2(mauthApp *MAuthApp, signed_string string, seconds_since_epoch int64) map[string]string
MakeAuthenticationHeadersV2 generates the formatted headers as a map for insertion into the request headers.
func MakeSignatureString ¶
func MakeSignatureString(mauthApp *MAuthApp, method string, url string, body string, epoch int64) string
MakeSignatureString generates the string to be signed as part of the MWS header
func MakeSignatureStringV2 ¶
func MakeSignatureStringV2(mauthApp *MAuthApp, method string, url string, body string, epoch int64) string
MakeSignatureStringV2 generates the string to be signed as part of the MWS header
func SignString ¶
SignString encrypts and encodes the string to sign
Types ¶
type MAuthApp ¶
type MAuthApp struct { AppId string RsaPrivateKey *rsa.PrivateKey DisableV1 bool }
MAuthApp struct holds all the necessary context for a MAuth App
func LoadMauth ¶
func LoadMauth(options MAuthOptions) (*MAuthApp, error)
LoadMauth loads the configuration when the private key content is in a file
Example ¶
Example of loading the MAuth configuration from a path
// given an APP_UUID var appUUID = "7D0B2A90-0825-4AD8-9C1F-E9851795D428" // and a path to a KeyFile var keyPath = filepath.Join("test", "private_key.pem") // create a MAuth client var client *MAuthApp client, err := LoadMauth(MAuthOptions{appUUID, keyPath, false}) if err != nil { log.Fatal("Unable to create client: ", err) } println("Created MAuth App for APP_UUID ", client.AppId)
Output:
func (*MAuthApp) CreateClient ¶
func (mauthApp *MAuthApp) CreateClient(baseUrl string) (client *MAuthClient, err error)
CreateClient creates a MAuth Client for the baseUrl
Example ¶
Example of creating a MAuth Client
// given an APP_UUID var appUUID = "7D0B2A90-0825-4AD8-9C1F-E9851795D428" // and a path to a KeyFile var keyPath = filepath.Join("test", "private_key.pem") // create a MAuth mAuthApp var mAuthApp *MAuthApp mAuthApp, err := LoadMauth(MAuthOptions{appUUID, keyPath, false}) if err != nil { log.Fatal("Unable to create mAuthApp: ", err) } // Define a base URL var baseURL = "https://innovate.imedidata.com" var client *MAuthClient client, err = mAuthApp.CreateClient(baseURL) if err != nil { log.Fatal("Unable to create MAuth Client: ", err) } println("Successfully created MAuth Client for APP: ", client.mauthApp.AppId)
Output:
type MAuthClient ¶
type MAuthClient struct {
// contains filtered or unexported fields
}
MAuthClient struct holds all the context for a MAuth Client
func (*MAuthClient) Delete ¶
func (mauthClient *MAuthClient) Delete(targetURL string) (response *http.Response, err error)
MAuthClient.Delete executes a DELETE request against targetURL
func (*MAuthClient) Get ¶
func (mauthClient *MAuthClient) Get(targetURL string) (response *http.Response, err error)
MAuthClient.Get executes a GET request against targetURL
Example ¶
Example of creating a MAuth Client and making a Get Request
// Get information on a User // http://developer.imedidata.com/desktop/ActionTopics/Users/Listing_User_Account_Details.htm // given an APP_UUID var appUUID = "7D0B2A90-0825-4AD8-9C1F-E9851795D428" // and a path to a KeyFile var keyPath = filepath.Join("test", "private_key.pem") // create a MAuth mAuthApp var mAuthApp *MAuthApp mAuthApp, err := LoadMauth(MAuthOptions{appUUID, keyPath, false}) if err != nil { log.Fatal("Unable to create mAuthApp: ", err) } // Define a base URL var baseURL = "https://innovate.imedidata.com" // Define and create the Client var client *MAuthClient client, err = mAuthApp.CreateClient(baseURL) if err != nil { log.Fatal("Unable to create MAuth Client: ", err) } // This is made-up var userUuid = "347942BF-9915-405D-BB20-6196597F3BE3" response, err := client.Get("api/v2/users/" + userUuid + ".json") println("Got a status code of", response.StatusCode, "for request for User UUID", userUuid)
Output:
func (*MAuthClient) Post ¶
func (mauthClient *MAuthClient) Post(targetURL string, data string) (response *http.Response, err error)
MAuthClient.Post executes a POST request against a targetURL
Example ¶
// Creating a Study Using a MAuth Client // http://developer.imedidata.com/desktop/ActionTopics/Studies/Creating_Studies.htm // given an APP_UUID var appUUID = "7D0B2A90-0825-4AD8-9C1F-E9851795D428" // and a path to a KeyFile var keyPath = filepath.Join("test", "private_key.pem") // create a MAuth mAuthApp var mAuthApp *MAuthApp mAuthApp, err := LoadMauth(MAuthOptions{appUUID, keyPath, false}) if err != nil { log.Fatal("Unable to create mAuthApp: ", err) } // Define a base URL var baseURL = "https://innovate.imedidata.com" // Define and create the Client client, err := mAuthApp.CreateClient(baseURL) if err != nil { log.Fatal("Unable to create MAuth Client: ", err) } // Define the constituent entity references var studyGroupUUID = "347942BF-9915-405D-BB20-6196597F3BE3" var studyUUID = "C3C79E4A-4BFD-4A72-89E9-724A4E6A9D95" // This is a slimmed down version of the structure from the reference above type studyDefinition struct { Number int `json:"number"` Name string `json:"name"` IsProduction bool `json:"is_production"` TherapeticArea string `json:"therapeutic_area"` FullDescription string `json:"full_description"` CompoundCode string `json:"compound_code"` DrugDevice string `json:"drug_device"` Title string `json:"title"` UUID string Protocol string `json:"protocol"` ParentUUID string `json:"parent_UUID"` EnrollmentTarget int `json:"enrollment_target"` OID string `json:"oid"` } // Create an instance of the new study study := &studyDefinition{ Number: 1, Name: "ABC1234", IsProduction: true, TherapeticArea: "Endocrine", FullDescription: "Some Sample Study", CompoundCode: "Mediflex", DrugDevice: "Drug", Title: "A sample Endocrine Study", UUID: studyUUID, Protocol: "ABC1234", ParentUUID: "", EnrollmentTarget: 150, OID: "ABC1234", } data, _ := json.Marshal(study) // POST www.imedidata.com/api/v2/study_groups/[study group uuid]/studies.json response, err := client.Post("api/v2/study_groups/"+studyGroupUUID+"/studies.json", string(data)) println("Got a status code of", response.StatusCode, "for request to create Study", studyUUID)
Output:
func (*MAuthClient) Put ¶
func (mauthClient *MAuthClient) Put(targetURL string, data string) (response *http.Response, err error)
MAuthClient.Put executes a PUT request against a targetURL
func (*MAuthClient) SetHeader ¶
func (client *MAuthClient) SetHeader(headerName, headerValue string)
add a Header
type MAuthOptions ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
go_mauth_client
Module
|
|
This package contains two examples of use for the MAuth client
|
This package contains two examples of use for the MAuth client |
imedidata
The imedidata package is an example of using the Go MAuth Client library to call the iMedidata API
|
The imedidata package is an example of using the Go MAuth Client library to call the iMedidata API |
medidata_apis
The package medidata_apis is one example of using the Go MAuth Client library to accessing a Medidata API
|
The package medidata_apis is one example of using the Go MAuth Client library to accessing a Medidata API |