()
| 69 | } |
| 70 | |
| 71 | func userID() string { |
| 72 | // TODO, once we add access token parsing, use that instead of id token. |
| 73 | // that will work with API_TOKEN as well. |
| 74 | if tok, err := identity.Peek(); err == nil && tok.IDClaims() != nil { |
| 75 | return tok.IDClaims().Subject |
| 76 | } |
| 77 | if username := os.Getenv(envir.GitHubUsername); username != "" { |
| 78 | const uidSalt = "d6134cd5-347d-4b7c-a2d0-295c0f677948" |
| 79 | const githubPrefix = "github:" |
| 80 | |
| 81 | // userID is a v5 UUID which is basically a SHA hash of the username. |
| 82 | // See https://www.uuidtools.com/uuid-versions-explained for a comparison of UUIDs. |
| 83 | return uuid.NewSHA1(uuid.MustParse(uidSalt), []byte(githubPrefix+username)).String() |
| 84 | } |
| 85 | return "" |
| 86 | } |
| 87 | |
| 88 | func orgID() string { |
| 89 | // TODO, once we add access token parsing, use that instead of id token. |
no test coverage detected