mirror of https://github.com/matrix-org/go-neb.git
Browse Source
Add AuthModule concept
Add AuthModule concept
- Register them like we are with Services. - Add `/configureAuth` endpoint to create/update auth. - Move ThirdPartyAuth out of the database layer since they are passed as params to `/admin/configureAuth`kegan/auth
7 changed files with 116 additions and 36 deletions
-
26src/github.com/matrix-org/go-neb/api.go
-
13src/github.com/matrix-org/go-neb/auth/auth.go
-
22src/github.com/matrix-org/go-neb/auth/github/github.go
-
9src/github.com/matrix-org/go-neb/database/db.go
-
42src/github.com/matrix-org/go-neb/database/schema.go
-
4src/github.com/matrix-org/go-neb/goneb.go
-
36src/github.com/matrix-org/go-neb/types/types.go
@ -0,0 +1,13 @@ |
|||||
|
package auth |
||||
|
|
||||
|
import ( |
||||
|
"github.com/matrix-org/go-neb/auth/github" |
||||
|
"github.com/matrix-org/go-neb/database" |
||||
|
"github.com/matrix-org/go-neb/types" |
||||
|
) |
||||
|
|
||||
|
// RegisterModules registers all known modules so they can be retrieved via
|
||||
|
// type.GetAuthModule
|
||||
|
func RegisterModules(db *database.ServiceDB) { |
||||
|
types.RegisterAuthModule(&github.AuthModule{Database: db}) |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package github |
||||
|
|
||||
|
import ( |
||||
|
"github.com/matrix-org/go-neb/database" |
||||
|
"github.com/matrix-org/go-neb/types" |
||||
|
) |
||||
|
|
||||
|
// AuthModule for github
|
||||
|
type AuthModule struct { |
||||
|
Database *database.ServiceDB |
||||
|
} |
||||
|
|
||||
|
// Type of the auth module
|
||||
|
func (*AuthModule) Type() string { |
||||
|
return "github" |
||||
|
} |
||||
|
|
||||
|
// Process a third-party auth request
|
||||
|
func (am *AuthModule) Process(tpa types.ThirdPartyAuth) (err error) { |
||||
|
_, err = am.Database.StoreThirdPartyAuth(tpa) |
||||
|
return |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue