func RetrieveAccessKeyFromRequest(ds auth.DataStore, req *http.Request) (*dm.AccessKey, error) { q := req.URL.Query() accessKeyId := q.Get("DSOCAccessKeyId") if accessKeyId == "" { return nil, nil } return ds.RetrieveAccessKey(accessKeyId) }
func CheckSignature(ds auth.DataStore, req *http.Request) (hasSignature bool, userId, consumerId string, err os.Error) { q := req.URL.Query() signature := q.Get("Signature") accessKeyId := q.Get("DSOCAccessKeyId") if signature == "" || accessKeyId == "" { return } hasSignature = true accessKey, err := ds.RetrieveAccessKey(accessKeyId) if err != nil { return } if accessKey == nil { err = ErrorInvalidAccessKeyId return } signit := NewSigner(accessKeyId, accessKey.PrivateKey) hasSignature, _, err = signit.CheckSignature(req) if hasSignature && err == nil { userId, consumerId = accessKey.UserId, accessKey.ConsumerId } return }