MCPcopy
hub / github.com/cloudflare/cloudflared / GetAppTokenIfExists

Function GetAppTokenIfExists

token/token.go:493–513  ·  view source on GitHub ↗
(appInfo *AppInfo)

Source from the content-addressed store, hash-verified

491}
492
493func GetAppTokenIfExists(appInfo *AppInfo) (string, error) {
494 path, err := GenerateAppTokenFilePathFromURL(appInfo.AppDomain, appInfo.AppAUD, keyName)
495 if err != nil {
496 return "", err
497 }
498 token, err := getTokenIfExists(path)
499 if err != nil {
500 return "", err
501 }
502 var payload jwtPayload
503 err = json.Unmarshal(token.UnsafePayloadWithoutVerification(), &payload)
504 if err != nil {
505 return "", err
506 }
507
508 if payload.isExpired() {
509 err := os.Remove(path)
510 return "", err
511 }
512 return token.CompactSerialize()
513}
514
515// GetTokenIfExists will return the token from local storage if it exists and not expired
516func getTokenIfExists(path string) (*jose.JSONWebSignature, error) {

Callers 4

loginFunction · 0.92
curlFunction · 0.92
generateTokenFunction · 0.92
getTokenFunction · 0.85

Calls 5

isExpiredMethod · 0.95
getTokenIfExistsFunction · 0.85
RemoveMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected