本文整理匯總了Golang中github.com/xtraclabs/roll/roll.Application.ClientSecret方法的典型用法代碼示例。如果您正苦於以下問題:Golang Application.ClientSecret方法的具體用法?Golang Application.ClientSecret怎麽用?Golang Application.ClientSecret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/xtraclabs/roll/roll.Application
的用法示例。
在下文中一共展示了Application.ClientSecret方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestAddAndRetrieveApp
func TestAddAndRetrieveApp(t *testing.T) {
app := new(roll.Application)
app.ApplicationName = "an app"
app.ClientID = "123"
app.ClientSecret = "hush"
app.DeveloperEmail = "[email protected]"
app.DeveloperID = "foo"
app.LoginProvider = "auth0"
app.RedirectURI = "neither here nor there"
appRepo := NewMBDAppRepo()
err := appRepo.CreateApplication(app)
if assert.Nil(t, err) {
defer appRepo.delete(app)
}
retapp, err := appRepo.RetrieveAppByNameAndDevEmail("an app", "[email protected]")
assert.Nil(t, err)
if assert.NotNil(t, app) {
assert.Equal(t, app.ApplicationName, retapp.ApplicationName)
assert.Equal(t, app.ClientID, retapp.ClientID)
assert.Equal(t, app.ClientSecret, retapp.ClientSecret)
assert.Equal(t, app.DeveloperEmail, retapp.DeveloperEmail)
assert.Equal(t, app.DeveloperID, retapp.DeveloperID)
assert.Equal(t, app.LoginProvider, retapp.LoginProvider)
assert.Equal(t, app.RedirectURI, retapp.RedirectURI)
}
retapp, err = appRepo.RetrieveApplication(app.ClientID, app.DeveloperID, false)
assert.Nil(t, err)
if assert.NotNil(t, app) {
assert.Equal(t, app.ApplicationName, retapp.ApplicationName)
assert.Equal(t, app.ClientID, retapp.ClientID)
assert.Equal(t, app.ClientSecret, retapp.ClientSecret)
assert.Equal(t, app.DeveloperEmail, retapp.DeveloperEmail)
assert.Equal(t, app.DeveloperID, retapp.DeveloperID)
assert.Equal(t, app.LoginProvider, retapp.LoginProvider)
assert.Equal(t, app.RedirectURI, retapp.RedirectURI)
}
retapp, err = appRepo.RetrieveApplication(app.ClientID, "huh", true)
assert.Nil(t, err)
if assert.NotNil(t, app) {
assert.Equal(t, app.ApplicationName, retapp.ApplicationName)
assert.Equal(t, app.ClientID, retapp.ClientID)
assert.Equal(t, app.ClientSecret, retapp.ClientSecret)
assert.Equal(t, app.DeveloperEmail, retapp.DeveloperEmail)
assert.Equal(t, app.DeveloperID, retapp.DeveloperID)
assert.Equal(t, app.LoginProvider, retapp.LoginProvider)
assert.Equal(t, app.RedirectURI, retapp.RedirectURI)
}
retapp, err = appRepo.SystemRetrieveApplication(app.ClientID)
assert.Nil(t, err)
assert.Equal(t, app.ClientID, retapp.ClientID)
retapp, err = appRepo.RetrieveApplication(app.ClientID, "huh", false)
assert.NotNil(t, err)
assert.Nil(t, retapp)
}
示例2: CreateApplication
func (ar *MariaDBAppRepo) CreateApplication(app *roll.Application) error {
//Generate a client secret as needed
if app.ClientSecret == "" {
clientSecret, err := secrets.GenerateClientSecret()
if err != nil {
return err
}
app.ClientSecret = clientSecret
}
//Check JWT flow parts are ok
if err := repos.CheckJWTCertParts(app); err != nil {
return err
}
//Insert the app
const appSql = `insert into rolldb.application(applicationName, clientId, clientSecret, developerEmail, developerId, loginProvider,
redirectUri,jwtFlowAudience, jwtFlowIssuer, jwtFlowPublicKey) values(?,?,?,?,?,?,?,?,?,?)
`
stmt, err := ar.db.Prepare(appSql)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(
app.ApplicationName,
app.ClientID,
app.ClientSecret,
app.DeveloperEmail,
app.DeveloperID,
app.LoginProvider,
app.RedirectURI,
app.JWTFlowAudience,
app.JWTFlowIssuer,
app.JWTFlowPublicKey,
)
if err != nil {
log.Info(err)
sqlErr := err.(*mysql.MySQLError)
switch sqlErr.Number {
case 1062:
log.Info("Duplicate app definition found")
return repos.NewDuplicationAppdefError(app.ApplicationName, app.DeveloperEmail)
default:
return err
}
}
return nil
}
示例3: CreateApplication
//CreateApplication stores an application definition in DynamoDB
func (dar *DynamoAppRepo) CreateApplication(app *roll.Application) error {
log.Info("create application")
//Make sure we are not creating a new application definition for an existing
//application name/developer email combination
existing, err := dar.RetrieveAppByNameAndDevEmail(app.ApplicationName, app.DeveloperEmail)
if err != nil {
log.Info("Internal error attempting to check for duplicate app: ", err.Error())
return err
}
if existing != nil {
log.Info("Duplicate app definition found")
return NewDuplicationAppdefError(app.ApplicationName, app.DeveloperEmail)
}
if app.ClientSecret == "" {
clientSecret, err := secrets.GenerateClientSecret()
if err != nil {
return err
}
app.ClientSecret = clientSecret
}
appAttrs := map[string]*dynamodb.AttributeValue{
ClientID: {S: aws.String(app.ClientID)},
ApplicationName: {S: aws.String(app.ApplicationName)},
ClientSecret: {S: aws.String(app.ClientSecret)},
DeveloperEmail: {S: aws.String(app.DeveloperEmail)},
DeveloperID: {S: aws.String(app.DeveloperID)},
RedirectUri: {S: aws.String(app.RedirectURI)},
LoginProvider: {S: aws.String(app.LoginProvider)},
}
if err := CheckJWTCertParts(app); err != nil {
return err
}
if app.JWTFlowPublicKey != "" {
appAttrs[JWTFlowPublicKey] = &dynamodb.AttributeValue{
S: aws.String(app.JWTFlowPublicKey),
}
appAttrs[JWTFlowIssuer] = &dynamodb.AttributeValue{
S: aws.String(app.JWTFlowIssuer),
}
appAttrs[JWTFlowAudience] = &dynamodb.AttributeValue{
S: aws.String(app.JWTFlowAudience),
}
}
params := &dynamodb.PutItemInput{
TableName: aws.String("Application"),
ConditionExpression: aws.String("attribute_not_exists(ClientID)"),
Item: appAttrs,
}
_, err = dar.client.PutItem(params)
return err
}