openai/openai-go
Publicmirrored from https://github.com/openai/openai-goAvailable
auth/types.go
37lines · modecode
| 1 | package auth |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "net/http" |
| 6 | ) |
| 7 | |
| 8 | type HTTPDoer interface { |
| 9 | Do(*http.Request) (*http.Response, error) |
| 10 | } |
| 11 | |
| 12 | type SubjectTokenType string |
| 13 | |
| 14 | const ( |
| 15 | SubjectTokenTypeJWT SubjectTokenType = "jwt" |
| 16 | SubjectTokenTypeID SubjectTokenType = "id" |
| 17 | ) |
| 18 | |
| 19 | type SubjectTokenProvider interface { |
| 20 | TokenType() SubjectTokenType |
| 21 | GetToken(ctx context.Context, httpClient HTTPDoer) (string, error) |
| 22 | } |
| 23 | |
| 24 | type WorkloadIdentity struct { |
| 25 | ClientID string |
| 26 | IdentityProviderID string |
| 27 | ServiceAccountID string |
| 28 | Provider SubjectTokenProvider |
| 29 | RefreshBufferSeconds int |
| 30 | } |
| 31 | |
| 32 | type TokenExchangeResponse struct { |
| 33 | AccessToken string `json:"access_token"` |
| 34 | IssuedTokenType string `json:"issued_token_type"` |
| 35 | TokenType string `json:"token_type"` |
| 36 | ExpiresIn *int `json:"expires_in,omitempty"` |
| 37 | } |
| 38 | |