mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2025-08-18 06:23:49 +02:00
Make the use of a user token configurable
This commit is contained in:
parent
2f27bd9e94
commit
27f2220a6e
4 changed files with 14 additions and 6 deletions
12
api/web.go
12
api/web.go
|
@ -30,6 +30,7 @@ type Config struct {
|
|||
SessionEncryptionKey []byte
|
||||
PAATokenGenerator TokenGeneratorFunc
|
||||
UserTokenGenerator UserTokenGeneratorFunc
|
||||
EnableUserToken bool
|
||||
OAuth2Config *oauth2.Config
|
||||
store *sessions.CookieStore
|
||||
OIDCTokenVerifier *oidc.IDTokenVerifier
|
||||
|
@ -170,10 +171,13 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, errors.New("unable to generate gateway credentials").Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
userToken, err := c.UserTokenGenerator(ctx, user)
|
||||
if err != nil {
|
||||
log.Printf("Cannot generate token for user %s due to %s", user, err)
|
||||
http.Error(w, errors.New("unable to generate gateway credentials").Error(), http.StatusInternalServerError)
|
||||
userToken := user
|
||||
if c.EnableUserToken {
|
||||
userToken, err = c.UserTokenGenerator(ctx, user)
|
||||
if err != nil {
|
||||
log.Printf("Cannot generate token for user %s due to %s", user, err)
|
||||
http.Error(w, errors.New("unable to generate gateway credentials").Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
// authenticated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue