Authenticate non-websocket HTTP request
(authMethod, secret, sid, remoteAddr string)
| 602 | |
| 603 | // Authenticate non-websocket HTTP request |
| 604 | func authFileRequest(authMethod, secret, sid, remoteAddr string) (types.Uid, []byte, error) { |
| 605 | var uid types.Uid |
| 606 | if authMethod != "" { |
| 607 | decodedSecret := make([]byte, base64.StdEncoding.DecodedLen(len(secret))) |
| 608 | n, err := base64.StdEncoding.Decode(decodedSecret, []byte(secret)) |
| 609 | if err != nil { |
| 610 | logs.Info.Println("media: invalid auth secret", authMethod, "'"+secret+"'") |
| 611 | return uid, nil, types.ErrMalformed |
| 612 | } |
| 613 | |
| 614 | if authhdl := store.Store.GetLogicalAuthHandler(authMethod); authhdl != nil { |
| 615 | rec, challenge, err := authhdl.Authenticate(decodedSecret[:n], remoteAddr) |
| 616 | if err != nil { |
| 617 | return uid, nil, err |
| 618 | } |
| 619 | if challenge != nil { |
| 620 | return uid, challenge, nil |
| 621 | } |
| 622 | uid = rec.Uid |
| 623 | } else { |
| 624 | logs.Info.Println("media: unknown auth method", authMethod) |
| 625 | return uid, nil, types.ErrMalformed |
| 626 | } |
| 627 | } else { |
| 628 | // Find the session, make sure it's appropriately authenticated. |
| 629 | sess := globals.sessionStore.Get(sid) |
| 630 | if sess != nil { |
| 631 | uid = sess.uid |
| 632 | } |
| 633 | } |
| 634 | return uid, nil, nil |
| 635 | } |
no test coverage detected
searching dependent graphs…