Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
chore: add default client id and secret
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed May 2, 2024
1 parent cd57d1e commit f336a32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion alby/alby.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ func NewAlbyOAuthService(logger *logrus.Logger, kvStore config.Config, appConfig
AuthURL: appConfig.AlbyOAuthAuthUrl,
AuthStyle: 2, // use HTTP Basic Authorization https://pkg.go.dev/golang.org/x/oauth2#AuthStyle
},
RedirectURL: appConfig.BaseUrl + "/api/alby/callback",
}

if appConfig.IsDefaultClientId() {
conf.RedirectURL = "https://getalby.com/hub/callback"
} else {
conf.RedirectURL = appConfig.BaseUrl + "/api/alby/callback"
}

albyOAuthSvc := &AlbyOAuthService{
Expand Down
2 changes: 1 addition & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ func (api *API) GetInfo(ctx context.Context) (*models.InfoResponse, error) {
info.Running = api.svc.lnClient != nil
info.BackendType = backendType
info.AlbyAuthUrl = api.svc.AlbyOAuthSvc.GetAuthUrl()
info.OAuthRedirect = api.svc.cfg.Env.AlbyClientId == api.svc.cfg.Env.AlbyHubClientId
info.OAuthRedirect = !api.svc.cfg.Env.IsDefaultClientId()
albyUserIdentifier, err := api.svc.AlbyOAuthSvc.GetUserIdentifier()
if err != nil {
api.svc.Logger.WithError(err).Error("Failed to get alby user identifier")
Expand Down
9 changes: 6 additions & 3 deletions models/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ type AppConfig struct {
LDKLogLevel string `envconfig:"LDK_LOG_LEVEL"`
MempoolApi string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"`
AlbyAPIURL string `envconfig:"ALBY_API_URL" default:"https://api.getalby.com"`
AlbyClientId string `envconfig:"ALBY_OAUTH_CLIENT_ID"`
AlbyHubClientId string `envconfig:"ALBY_HUB_OAUTH_CLIENT_ID"`
AlbyClientSecret string `envconfig:"ALBY_OAUTH_CLIENT_SECRET"`
AlbyClientId string `envconfig:"ALBY_OAUTH_CLIENT_ID" default:"J2PbXS1yOf"`
AlbyClientSecret string `envconfig:"ALBY_OAUTH_CLIENT_SECRET" default:"rABK2n16IWjLTZ9M1uKU"`
AlbyOAuthAuthUrl string `envconfig:"ALBY_OAUTH_AUTH_URL" default:"https://getalby.com/oauth"`
BaseUrl string `envconfig:"BASE_URL" default:"http://localhost:8080"`
FrontendUrl string `envconfig:"FRONTEND_URL"`
LogEvents bool `envconfig:"LOG_EVENTS" default:"false"`
ConnectAlbyAccount bool `envconfig:"CONNECT_ALBY_ACCOUNT" default:"true"`
}

func (c *AppConfig) IsDefaultClientId() bool {
return c.AlbyClientId == "J2PbXS1yOf"
}

type Config interface {
Get(key string, encryptionKey string) (string, error)
SetIgnore(key string, value string, encryptionKey string)
Expand Down

0 comments on commit f336a32

Please sign in to comment.