MCPcopy Index your code
hub / github.com/cloudfoundry/cli / BuildTokenString

Function BuildTokenString

integration/helpers/token.go:14–24  ·  view source on GitHub ↗

BuildTokenString returns a string typed JSON web token with the specified expiration time

(expiration time.Time)

Source from the content-addressed store, hash-verified

12
13// BuildTokenString returns a string typed JSON web token with the specified expiration time
14func BuildTokenString(expiration time.Time) string {
15 c := jws.Claims{}
16 c.SetExpiration(expiration)
17 c.Set("user_name", "some-user")
18 c.Set("user_id", "some-guid")
19 c.Set("origin", "uaa")
20 token := jws.NewJWT(c, crypto.Unsecured)
21 tokenBytes, err := token.Serialize(nil)
22 Expect(err).NotTo(HaveOccurred())
23 return string(tokenBytes)
24}
25
26// ParseTokenString takes a string typed token and returns a jwt.JWT struct representation of that token
27func ParseTokenString(token string) jwt.JWT {

Callers 2

token_test.goFile · 0.92
AddLoginRoutesFunction · 0.70

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected