(c *gin.Context, needsPaid bool, allowFallbackPaid bool, proxy string)
| 1815 | } |
| 1816 | |
| 1817 | func (h *Handler) secretFromAuthorization(c *gin.Context, needsPaid bool, allowFallbackPaid bool, proxy string) (*tokens.Secret, int, error) { |
| 1818 | secret := h.token.GetSecret() |
| 1819 | if needsPaid || allowFallbackPaid { |
| 1820 | secret = h.token.GetPaidSecret() |
| 1821 | } |
| 1822 | |
| 1823 | authToken, teamAccountID, hasAuthorizationTeamID := authorizationTokenAndTeam(c) |
| 1824 | if authToken != "" && os.Getenv("Authorization") != "" && authToken == os.Getenv("Authorization") { |
| 1825 | authToken = "" |
| 1826 | } |
| 1827 | if authToken != "" { |
| 1828 | if strings.HasPrefix(authToken, "eyJhbGciOiJSUzI1NiI") { |
| 1829 | secret = h.token.GenerateTempToken(authToken) |
| 1830 | } else if isUUID(authToken) { |
| 1831 | secret = h.token.GenerateDeviceId(authToken) |
| 1832 | } else if hasAuthorizationTeamID || teamAccountID != "" { |
| 1833 | accessToken, status, err := h.accessTokenFromRefreshToken(authToken, proxy) |
| 1834 | if err != nil { |
| 1835 | return nil, status, err |
| 1836 | } |
| 1837 | secret = h.token.GenerateTempToken(accessToken) |
| 1838 | } |
| 1839 | } |
| 1840 | if needsPaid && (secret == nil || secret.Token == "" || secret.IsFree) && !allowFallbackPaid { |
| 1841 | return nil, 0, nil |
| 1842 | } |
| 1843 | return secret.WithTeamUserID(teamAccountID), 0, nil |
| 1844 | } |
| 1845 | |
| 1846 | func (h *Handler) accessTokenFromRefreshToken(refreshToken string, proxy string) (string, int, error) { |
| 1847 | client := bogdanfinn.NewStdClient() |
no test coverage detected