MCPcopy Index your code
hub / github.com/coder/coder / authenticateBearerTokenRequest

Method authenticateBearerTokenRequest

coderd/coderdtest/oidctest/idp.go:859–874  ·  view source on GitHub ↗

authenticateBearerTokenRequest enforces the access token is valid.

(t testing.TB, req *http.Request)

Source from the content-addressed store, hash-verified

857
858// authenticateBearerTokenRequest enforces the access token is valid.
859func (f *FakeIDP) authenticateBearerTokenRequest(t testing.TB, req *http.Request) (string, error) {
860 t.Helper()
861
862 auth := req.Header.Get("Authorization")
863 token := strings.TrimPrefix(auth, "Bearer ")
864 authToken, ok := f.accessTokens.Load(token)
865 if !ok {
866 return "", xerrors.New("invalid access token")
867 }
868
869 if !authToken.exp.IsZero() && authToken.exp.Before(time.Now()) {
870 return "", xerrors.New("access token expired")
871 }
872
873 return token, nil
874}
875
876// authenticateOIDCClientRequest enforces the client_id and client_secret are valid.
877func (f *FakeIDP) authenticateOIDCClientRequest(t testing.TB, req *http.Request) (url.Values, error) {

Callers 1

httpHandlerMethod · 0.95

Calls 5

HelperMethod · 0.65
GetMethod · 0.65
NewMethod · 0.65
LoadMethod · 0.45
IsZeroMethod · 0.45

Tested by

no test coverage detected