gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

config.go (1446B)


      1 package server
      2 
      3 import (
      4 	"net/http"
      5 	"time"
      6 
      7 	"github.com/superseriousbusiness/oauth2/v4"
      8 )
      9 
     10 // Config configuration parameters
     11 type Config struct {
     12 	TokenType                   string                // token type
     13 	AllowGetAccessRequest       bool                  // to allow GET requests for the token
     14 	AllowedResponseTypes        []oauth2.ResponseType // allow the authorization type
     15 	AllowedGrantTypes           []oauth2.GrantType    // allow the grant type
     16 	AllowedCodeChallengeMethods []oauth2.CodeChallengeMethod
     17 	ForcePKCE                   bool
     18 }
     19 
     20 // NewConfig create to configuration instance
     21 func NewConfig() *Config {
     22 	return &Config{
     23 		TokenType:            "Bearer",
     24 		AllowedResponseTypes: []oauth2.ResponseType{oauth2.Code, oauth2.Token},
     25 		AllowedGrantTypes: []oauth2.GrantType{
     26 			oauth2.AuthorizationCode,
     27 			oauth2.PasswordCredentials,
     28 			oauth2.ClientCredentials,
     29 			oauth2.Refreshing,
     30 		},
     31 		AllowedCodeChallengeMethods: []oauth2.CodeChallengeMethod{
     32 			oauth2.CodeChallengePlain,
     33 			oauth2.CodeChallengeS256,
     34 		},
     35 	}
     36 }
     37 
     38 // AuthorizeRequest authorization request
     39 type AuthorizeRequest struct {
     40 	ResponseType        oauth2.ResponseType
     41 	ClientID            string
     42 	Scope               string
     43 	RedirectURI         string
     44 	State               string
     45 	UserID              string
     46 	CodeChallenge       string
     47 	CodeChallengeMethod oauth2.CodeChallengeMethod
     48 	AccessTokenExp      time.Duration
     49 	Request             *http.Request
     50 }