github.com/Axway/agent-sdk@v1.1.101/pkg/authz/oauth/oktaprovider.go (about)

     1  package oauth
     2  
     3  const (
     4  	oktaApplicationType  = "application_type"
     5  	oktaAppTypeService   = "service"
     6  	oktaAppTypeWeb       = "web"
     7  	oktaAuthHeaderPrefix = "SSWS"
     8  )
     9  
    10  type okta struct {
    11  }
    12  
    13  func (i *okta) getAuthorizationHeaderPrefix() string {
    14  	return oktaAuthHeaderPrefix
    15  }
    16  
    17  func (i *okta) preProcessClientRequest(clientRequest *clientMetadata) {
    18  	if len(clientRequest.extraProperties) == 0 {
    19  		clientRequest.extraProperties = make(map[string]string)
    20  	}
    21  	appType, ok := clientRequest.extraProperties[oktaApplicationType]
    22  	if !ok {
    23  		appType = oktaAppTypeService
    24  	}
    25  
    26  	for _, grantTypes := range clientRequest.GrantTypes {
    27  		if grantTypes != GrantTypeClientCredentials {
    28  			appType = oktaAppTypeWeb
    29  		} else {
    30  			if len(clientRequest.ResponseTypes) == 0 {
    31  				clientRequest.ResponseTypes = []string{AuthResponseToken}
    32  			}
    33  		}
    34  	}
    35  	clientRequest.extraProperties[oktaApplicationType] = appType
    36  }