mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Refactored and added client credentials flow
This commit is contained in:
parent
f912890a2d
commit
f490eb4fc4
9 changed files with 113 additions and 41 deletions
28
internal/flows/login.go
Normal file
28
internal/flows/login.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package flows
|
||||
|
||||
import (
|
||||
opaal "davidallendj/opaal/internal"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Login(config *opaal.Config) error {
|
||||
if config == nil {
|
||||
return fmt.Errorf("config is not valid")
|
||||
}
|
||||
|
||||
// initialize client that will be used throughout login flow
|
||||
server := opaal.NewServerWithConfig(config)
|
||||
client := opaal.NewClientWithConfig(config)
|
||||
|
||||
fmt.Printf("grant type: %v\n", config.GrantType)
|
||||
|
||||
if config.GrantType == "authorization_code" {
|
||||
AuthorizationCode(config, server, client)
|
||||
} else if config.GrantType == "client_credentials" {
|
||||
ClientCredentials(config, server, client)
|
||||
} else {
|
||||
return fmt.Errorf("invalid grant type")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue