|
@@ -14,10 +14,23 @@ const (
|
|
|
OAuthGoogle OAuthIntegrationClient = "google"
|
|
OAuthGoogle OAuthIntegrationClient = "google"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// SharedOAuthModel stores general fields needed for OAuth Integration
|
|
|
|
|
+type SharedOAuthModel struct {
|
|
|
|
|
+ // The ID issued to the client
|
|
|
|
|
+ ClientID []byte `json:"client-id"`
|
|
|
|
|
+
|
|
|
|
|
+ // The end-users's access token
|
|
|
|
|
+ AccessToken []byte `json:"access-token"`
|
|
|
|
|
+
|
|
|
|
|
+ // The end-user's refresh token
|
|
|
|
|
+ RefreshToken []byte `json:"refresh-token"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// OAuthIntegration is an auth mechanism that uses oauth
|
|
// OAuthIntegration is an auth mechanism that uses oauth
|
|
|
// https://tools.ietf.org/html/rfc6749
|
|
// https://tools.ietf.org/html/rfc6749
|
|
|
type OAuthIntegration struct {
|
|
type OAuthIntegration struct {
|
|
|
gorm.Model
|
|
gorm.Model
|
|
|
|
|
+ SharedOAuthModel
|
|
|
|
|
|
|
|
// The name of the auth mechanism
|
|
// The name of the auth mechanism
|
|
|
Client OAuthIntegrationClient `json:"client"`
|
|
Client OAuthIntegrationClient `json:"client"`
|
|
@@ -31,15 +44,16 @@ type OAuthIntegration struct {
|
|
|
// ------------------------------------------------------------------
|
|
// ------------------------------------------------------------------
|
|
|
// All fields encrypted before storage.
|
|
// All fields encrypted before storage.
|
|
|
// ------------------------------------------------------------------
|
|
// ------------------------------------------------------------------
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- // The ID issued to the client
|
|
|
|
|
- ClientID []byte `json:"client-id"`
|
|
|
|
|
-
|
|
|
|
|
- // The end-users's access token
|
|
|
|
|
- AccessToken []byte `json:"access-token"`
|
|
|
|
|
|
|
+// GithubAppOAuthIntegration is the model used for storing github app oauth data
|
|
|
|
|
+// Unlike the above, this model is tied to a specific user, not a project
|
|
|
|
|
+type GithubAppOAuthIntegration struct {
|
|
|
|
|
+ gorm.Model
|
|
|
|
|
+ SharedOAuthModel
|
|
|
|
|
|
|
|
- // The end-user's refresh token
|
|
|
|
|
- RefreshToken []byte `json:"refresh-token"`
|
|
|
|
|
|
|
+ // The id of the user that linked this auth mechanism
|
|
|
|
|
+ UserID uint `json:"user_id"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// OAuthIntegrationExternal is an OAuthIntegration to be shared over REST
|
|
// OAuthIntegrationExternal is an OAuthIntegration to be shared over REST
|