id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c10200 | string(fs.PathSeparator()))
return mount.Mkdir(innerPath, perm)
} | |
c10201 | == "/" {
return innerFileInfo{FileInfo: fi, name: filepath.Base(name)}, err
}
return fi, err
} | |
c10202 | its result.
err := fs.Mkdir(path, perm)
if err != nil {
// Handle arguments like "foo/." by
// double-checking that directory doesn't exist.
dir, err1 := fs.Lstat(path)
if err1 == nil && dir.IsDir() {
return nil
}
return err
}
return nil
} | |
c10203 |
err1 := RemoveAll(fs, path+string(fs.PathSeparator())+fi.Name())
if err == nil {
err = err1
}
}
// Remove directory itself.
err1 := fs.Remove(path)
if err1 == nil || os.IsNotExist(err1) {
return nil
}
if err == nil {
err = err1
}
return err
} | |
c10204 | return base64.RawURLEncoding.EncodeToString([]byte(token)), nil
} | |
c10205 | generaterefresh {
rtoken := uuid.NewRandom()
refreshtoken = base64.RawURLEncoding.EncodeToString([]byte(rtoken))
}
return
} | |
c10206 | match
if redirect.Host != base.Host {
return nil, nil, newUriValidationError("host mismatch", baseUrl, redirectUrl)
}
// resolve references to base url
retBaseUrl = (&url.URL{Scheme: base.Scheme, Host: base.Host, Path: "/"}).ResolveReference(&url.URL{Path: base.Path})
retRedirectUrl = (&url.URL{Scheme: base.Sc... | |
c10207 | return realRedirectUri, nil
}
// if there was an error that is not a validation error, return it
if _, iok := err.(UriValidationError); !iok {
return "", err
}
}
return "", newUriValidationError("urls don't validate", baseUriList, redirectUri)
} | |
c10208 | strings.TrimRight(base.Path, "/") + "/"
if !strings.HasPrefix(redirect.Path, requiredPrefix) {
return "", newUriValidationError("path prefix doesn't match", baseUri, redirectUri)
}
return redirect.String(),nil
} | |
c10209 | {
return slist[0]
}
} else {
return baseUriList
}
return ""
} | |
c10210 | string) {
r.SetErrorUri(id, description, "", "")
} | |
c10211 |
r.SetErrorUri(id, description, "", state)
} | |
c10212 |
r.StatusCode = r.ErrorStatusCode
if r.StatusCode != 200 {
r.StatusText = description
} else {
r.StatusText = ""
}
r.Output = make(ResponseData) // clear output
r.Output["error"] = id
r.Output["error_description"] = description
if uri != "" {
r.Output["error_uri"] = uri
}
if state != "" {
r.Output["st... | |
c10213 | {
// set redirect parameters
r.Type = REDIRECT
r.URL = url
} | |
c10214 | stdlib URL#String() doesn't make that easy to accomplish, so build this ourselves
if r.RedirectInFragment {
u.Fragment = ""
redirectURI := u.String() + "#" + q.Encode()
return redirectURI, nil
}
// Otherwise, update the query and encode normally
u.RawQuery = q.Encode()
u.Fragment = ""
return u.String(), n... | |
c10215 | with it
if w.Header().Get("Content-Type") == "" {
w.Header().Set("Content-Type", "application/json")
}
w.WriteHeader(rs.StatusCode)
encoder := json.NewEncoder(w)
err := encoder.Encode(rs.Output)
if err != nil {
return err
}
}
return nil
} | |
c10216 | {
if k == rt {
return true
}
}
return false
} | |
c10217 | {
for _, k := range t {
if k == rt {
return true
}
}
return false
} | |
c10218 | ErrorStatusCode: 200,
AllowClientSecretInParams: false,
AllowGetAccessRequest: false,
RetainTokenAfterRefresh: false,
}
} | |
c10219 | storage,
AuthorizeTokenGen: &AuthorizeTokenGenDefault{},
AccessTokenGen: &AccessTokenGenDefault{},
Now: time.Now,
Logger: &LoggerDefault{},
}
} | |
c10220 | = s.Config.ErrorStatusCode
return r
} | |
c10221 | data is nil")
return nil
}
if ret.AccessData.Client == nil {
s.setErrorAndLog(w, E_UNAUTHORIZED_CLIENT, nil, "handle_info_request=%s", "access data client is nil")
return nil
}
if ret.AccessData.Client.GetRedirectUri() == "" {
s.setErrorAndLog(w, E_UNAUTHORIZED_CLIENT, nil, "handle_info_request=%s", "acces... | |
c10222 | time.Second
if ir.AccessData.RefreshToken != "" {
w.Output["refresh_token"] = ir.AccessData.RefreshToken
}
if ir.AccessData.Scope != "" {
w.Output["scope"] = ir.AccessData.Scope
}
} | |
c10223 |
switch grantType {
case AUTHORIZATION_CODE:
return s.handleAuthorizationCodeRequest(w, r)
case REFRESH_TOKEN:
return s.handleRefreshTokenRequest(w, r)
case PASSWORD:
return s.handlePasswordRequest(w, r)
case CLIENT_CREDENTIALS:
return s.handleClientCredentialsRequest(w, r)
case ASSERTION:
re... | |
c10224 | s.setErrorAndLog(w, E_UNAUTHORIZED_CLIENT, nil, "get_client=%s, client_id=%v", "client check failed", client.GetId())
return nil
}
if client.GetRedirectUri() == "" {
s.setErrorAndLog(w, E_UNAUTHORIZED_CLIENT, nil, "get_client=%s", "client redirect uri is empty")
return nil
}
return client
} | |
c10225 | return d.ExpireAt().Before(t)
} | |
c10226 | d.CreatedAt.Add(time.Duration(d.ExpiresIn) * time.Second)
} | |
c10227 | []string{"public"},
"id_token_signing_alg_values_supported": []string{"RS256"},
"scopes_supported": []string{"openid", "email", "profile"},
"token_endpoint_auth_methods_supported": []string{"client_secret_basic"},
"claims_supported": []string{
"aud", "email", "email_verified",... | |
c10228 | data: %v", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Length", strconv.Itoa(len(raw)))
w.Write(raw)
} | |
c10229 | return fmt.Errorf("failed to serialize token: %v", err)
}
resp.Output["id_token"] = raw
return nil
}()
// Record errors as internal server errors.
if resp.InternalError != nil {
resp.IsError = true
resp.ErrorId = osin.E_SERVER_ERROR
}
} | |
c10230 | the less secure method of extracting the plain text secret from the client for comparison
return client.GetSecret() == secret
}
} | |
c10231 | client_id and client_secret pairs as per
// https://tools.ietf.org/html/rfc6749#section-2.3.1
username, err := url.QueryUnescape(pair[0])
if err != nil {
return nil, err
}
password, err := url.QueryUnescape(pair[1])
if err != nil {
return nil, err
}
return &BasicAuth{Username: username, Password: passwo... | |
c10232 | type is bearer else query string access token would be returned
if len(s) > 0 && strings.ToLower(s[0]) == "bearer" {
token = s[1]
}
}
return &BearerAuth{Code: token}
} | |
c10233 | err != nil {
s.setErrorAndLog(w, E_INVALID_REQUEST, err, "get_client_auth=%s", "check auth error")
return nil
}
if auth == nil {
s.setErrorAndLog(w, E_INVALID_REQUEST, errors.New("Client authentication not sent"), "get_client_auth=%s", "client authentication not sent")
return nil
}
return auth
} | |
c10234 | size := 0
for _, k := range p.Key {
if k == ParamCharacter || k == WildcardCharacter {
size++
}
}
if size > rt.SizeHint {
rt.SizeHint = size
}
}
}
for _, r := range statics {
rt.static[r.Key] = r.Value
}
if err := rt.param.build(params, 1, 0, make(map[int]struct{})); err != nil {
... | |
c10235 | == name {
return p.Value
}
}
return ""
} | |
c10236 | {
return err
}
case WildcardCharacter:
r := records[0]
name := r.Key[depth+1 : len(r.Key)-1]
r.paramNames = append(r.paramNames, name)
r.Key = ""
da.bc[idx].SetWildcardParam()
if err := da.build(records, nextIndex(base, sib.c), 0, usedBase); err != nil {
return err
}
default:
if ... | |
c10237 | da.bc[i].SetBase(base)
} | |
c10238 |
da.bc[i].SetCheck(check)
} | |
c10239 | return nil, fmt.Errorf("denco: path parameter `%v' is duplicated in the key `%v'", name, r.Key)
}
dups[name] = true
}
return &node{data: r.Value, paramNames: r.paramNames}, nil
} | |
c10240 | Record {
return Record{
Key: key,
Value: value,
}
} | |
c10241 | += termChar
params = append(params, &record{Record: r})
} else {
statics = append(statics, &record{Record: r})
}
}
return statics, params
} | |
c10242 | return rs[i].Key < rs[j].Key
} | |
c10243 | rs[i], rs[j] = rs[j], rs[i]
} | |
c10244 | _ strfmt.Registry) error {
encoded := base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return r.SetHeaderParam("Authorization", "Basic "+encoded)
})
} | |
c10245 | "header" {
return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error {
return r.SetHeaderParam(name, value)
})
}
return nil
} | |
c10246 | {
return r.SetHeaderParam("Authorization", "Bearer "+token)
})
} | |
c10247 |
return f.Data.Read(p)
} | |
c10248 | (interface{}, error) {
return read(resp, consumer)
} | |
c10249 | Response: payload,
Code: code,
}
} | |
c10250 | make(map[string]map[string]runtime.OperationHandler),
ServeError: errors.ServeError,
Models: make(map[string]func() interface{}),
formats: strfmt.NewFormats(),
}
return api.WithJSONDefaults()
} | |
c10251 | = runtime.JSONConsumer()
d.producers[runtime.JSONMime] = runtime.JSONProducer()
return d
} | |
c10252 | runtime.JSONMime)
delete(d.producers, runtime.JSONMime)
return d
} | |
c10253 | == nil {
d.formats = strfmt.NewFormats()
}
return d.formats
} | |
c10254 | == nil {
d.authenticators = make(map[string]runtime.Authenticator)
}
d.authenticators[scheme] = handler
} | |
c10255 | == nil {
d.consumers = make(map[string]runtime.Consumer, 10)
}
d.consumers[strings.ToLower(mediaType)] = handler
} | |
c10256 | == nil {
d.producers = make(map[string]runtime.Producer, 10)
}
d.producers[strings.ToLower(mediaType)] = handler
} | |
c10257 |
}
um := strings.ToUpper(method)
if b, ok := d.operations[um]; !ok || b == nil {
d.operations[um] = make(map[string]runtime.OperationHandler)
}
d.operations[um][path] = handler
} | |
c10258 | nil {
return nil, false
}
if pi, ok := d.operations[strings.ToUpper(method)]; ok {
h, ok := pi[path]
return h, ok
}
return nil, false
} | |
c10259 |
}
var definedAuths []string
for k := range d.spec.Spec().SecurityDefinitions {
definedAuths = append(definedAuths, k)
}
if err := d.verify("consumes", consumes, d.analyzer.RequiredConsumes()); err != nil {
return err
}
if err := d.verify("produces", produces, d.analyzer.RequiredProduces()); err != nil {
... | |
c10260 |
return vv[len(vv)-1]
}
return ""
} | |
c10261 | ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.MethodNotAllowed(r.Method, others))
return
}
ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.NotFound("path %s was not found", r.URL.EscapedPath()))
})
} | |
c10262 | path)
debugLog("adding route %s %s %q", method, fp, operation.ID)
builder.AddRoute(method, fp, operation)
}
}
}
return builder.Build()
} | |
c10263 |
})
if !applies {
return false, nil, nil
}
if err != nil {
route.Authenticator = ra
return true, nil, err
}
lastResult = princ
}
}
route.Authenticator = ra
return true, lastResult, nil
} | |
c10264 | ra.AllowsAnonymous() {
return true
}
}
return false
} | |
c10265 |
if err != nil {
lastError = err
}
continue
}
return applies, usr, nil
}
if allowsAnon && lastError == nil {
route.Authenticator = &anonAuth
return true, nil, lastError
}
return lastError != nil, nil, lastError
} | |
c10266 | units.HumanSize(float64(b)), nil
} | |
c10267 | return err
}
*b = ByteSize(int(sz))
return nil
} | |
c10268 | strfmt.Registry) error {
return fn(req, reg)
} | |
c10269 | {
// use context to lookup routes
route, rCtx, _ := ctx.RouteInfo(r)
if rCtx != nil {
r = rCtx
}
route.Handler.ServeHTTP(rw, r)
})
} | |
c10270 | ioutil.ReadAll(r)
if err != nil {
return err
}
return yaml.Unmarshal(buf, v)
})
} | |
c10271 | yaml.Marshal(v) // can't make this error come up
_, err := w.Write(b)
return err
})
} | |
c10272 |
}
if scoped, ok := params.(*ScopedAuthRequest); ok {
return handler(scoped.Request)
}
return false, nil, nil
})
} | |
c10273 | ok := params.(*ScopedAuthRequest); ok {
return handler(request)
}
return false, nil, nil
})
} | |
c10274 | usr, pass, ok := r.BasicAuth(); ok {
ctx, p, err := authenticate(r.Context(), usr, pass)
if err != nil {
ctx = context.WithValue(ctx, failedBasicAuth, realm)
}
*r = *r.WithContext(ctx)
return true, p, err
}
*r = *r.WithContext(context.WithValue(r.Context(), failedBasicAuth, realm))
return fals... | |
c10275 | r.URL.Query().Get(name) }
}
return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) {
token := getToken(r)
if token == "" {
return false, nil, nil
}
p, err := authenticate(token)
return true, p, err
})
} | |
c10276 | := runtime.ContentType(r.Request.Header)
if token == "" && (ct == "application/x-www-form-urlencoded" || ct == "multipart/form-data") {
token = r.Request.FormValue("access_token")
}
if token == "" {
return false, nil, nil
}
p, err := authenticate(token, r.RequiredScopes)
return true, p, err
})
} | |
c10277 | nil {
return "", "", errors.NewParseError(HeaderContentType, "header", orig, err)
}
if cs, ok := opts[charsetKey]; ok {
return mt, cs, nil
}
return mt, "", nil
} | |
c10278 | dec.UseNumber() // preserve number formats
return dec.Decode(data)
})
} | |
c10279 | enc.SetEscapeHTML(false)
return enc.Encode(data)
})
} | |
c10280 | return nil
}
if swag.ContainsStringsCI(allowed, "*/*") {
return nil
}
parts := strings.Split(actual, "/")
if len(parts) == 2 && swag.ContainsStringsCI(allowed, parts[0]+"/*") {
return nil
}
return errors.InvalidContentType(actual, allowed)
} | |
c10281 | == "" {
r.RedocURL = redocLatest
}
if r.Title == "" {
r.Title = "API documentation"
}
} | |
c10282 | *http.Request) {
if r.URL.Path == pth {
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
rw.WriteHeader(http.StatusOK)
_, _ = rw.Write(b)
return
}
if next == nil {
rw.Header().Set("Content-Type", "text/plain")
rw.WriteHeader(http.StatusNotFound)
_, _ = rw.Write([]byte(fmt.Sprint... | |
c10283 |
return mn == "POST" || mn == "PUT" || mn == "PATCH" || mn == "DELETE"
} | |
c10284 | return mn == "GET" || mn == "HEAD"
} | |
c10285 | len(r.TransferEncoding) > 0 || r.ContentLength > 0
} | |
c10286 | body)
if err != nil {
return nil, err
}
req.Header.Add(HeaderContentType, JSONMime)
req.Header.Add(HeaderAccept, JSONMime)
return req, nil
} | |
c10287 | hv {
return vv[len(vv)-1]
}
return ""
} | |
c10288 | := ReadSingleValue(values, name)
return swag.SplitByFormat(v, collectionFormat)
} | |
c10289 |
value, hasKey = v[key]
if !hasKey {
return
}
if len(value) == 0 {
return
}
hasValue = true
return
} | |
c10290 | writer,
header: make(http.Header),
query: make(url.Values),
timeout: DefaultTimeout,
}, nil
} | |
c10291 | {
return r.buildHTTP(mediaType, basePath, producers, registry, nil)
} | |
c10292 | result[key] = append([]string{}, value...)
}
return result
} | |
c10293 | == nil {
r.pathParams = make(map[string]string)
}
r.pathParams[name] = value
return nil
} | |
c10294 | }
}
if r.fileFields == nil {
r.fileFields = make(map[string][]runtime.NamedReadCloser)
}
if r.formFields == nil {
r.formFields = make(url.Values)
}
r.fileFields[name] = files
return nil
} | |
c10295 | error {
r.timeout = timeout
return nil
} | |
c10296 | error {
return fn(reader, data)
} | |
c10297 | error {
return f(writer, data)
} | |
c10298 | error {
return f(r, principal)
} | |
c10299 | []tls.Certificate{cert}
}
cfg.InsecureSkipVerify = opts.InsecureSkipVerify
// When no CA certificate is provided, default to the system cert pool
// that way when a request is made to a server known by the system trust store,
// the name is still verified
if opts.LoadedCA != nil {
caCertPool := x509.NewCertP... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.