MCPcopy Index your code
hub / github.com/docker/docker-agent / parseAuthInfo

Function parseAuthInfo

cmd/root/debug_auth.go:80–105  ·  view source on GitHub ↗
(token string)

Source from the content-addressed store, hash-verified

78}
79
80func parseAuthInfo(token string) (*authInfo, error) {
81 parsed, _, err := jwt.NewParser().ParseUnverified(token, jwt.MapClaims{})
82 if err != nil {
83 return nil, err
84 }
85
86 info := &authInfo{
87 Token: token,
88 }
89
90 if sub, err := parsed.Claims.GetSubject(); err == nil {
91 info.Subject = sub
92 }
93 if iss, err := parsed.Claims.GetIssuer(); err == nil {
94 info.Issuer = iss
95 }
96 if iat, err := parsed.Claims.GetIssuedAt(); err == nil && iat != nil {
97 info.IssuedAt = iat.Time
98 }
99 if exp, err := parsed.Claims.GetExpirationTime(); err == nil && exp != nil {
100 info.ExpiresAt = exp.Time
101 info.Expired = exp.Before(time.Now())
102 }
103
104 return info, nil
105}
106
107func printAuthInfoText(w io.Writer, info *authInfo) {
108 const previewLen = 10

Callers 4

newDebugAuthCmdFunction · 0.85

Calls 1

NowMethod · 0.80

Tested by 3