-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
521f688
commit 5c982e0
Showing
10 changed files
with
314 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package credentials | ||
|
||
type Credentials struct { | ||
AccessKeyId string | ||
AccessKeySecret string | ||
SecurityToken string | ||
BearerToken string | ||
} | ||
|
||
type CredentialsProvider interface { | ||
GetCredentials() (cc *Credentials, err error) | ||
} | ||
|
||
type StaticAKCredentialsProvider struct { | ||
AccessKeyId string | ||
AccessKeySecret string | ||
} | ||
|
||
func NewStaticAKCredentialsProvider(accessKeyId, accessKeySecret string) *StaticAKCredentialsProvider { | ||
return &StaticAKCredentialsProvider{ | ||
AccessKeyId: accessKeyId, | ||
AccessKeySecret: accessKeySecret, | ||
} | ||
} | ||
|
||
func (provider *StaticAKCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
AccessKeyId: provider.AccessKeyId, | ||
AccessKeySecret: provider.AccessKeySecret, | ||
} | ||
return | ||
} | ||
|
||
type StaticSTSCredentialsProvider struct { | ||
AccessKeyId string | ||
AccessKeySecret string | ||
SecurityToken string | ||
} | ||
|
||
func NewStaticSTSCredentialsProvider(accessKeyId, accessKeySecret, securityToken string) *StaticSTSCredentialsProvider { | ||
return &StaticSTSCredentialsProvider{ | ||
AccessKeyId: accessKeyId, | ||
AccessKeySecret: accessKeySecret, | ||
SecurityToken: securityToken, | ||
} | ||
} | ||
|
||
func (provider *StaticSTSCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
AccessKeyId: provider.AccessKeyId, | ||
AccessKeySecret: provider.AccessKeySecret, | ||
SecurityToken: provider.SecurityToken, | ||
} | ||
return | ||
} | ||
|
||
type BearerTokenCredentialsProvider struct { | ||
BearerToken string | ||
} | ||
|
||
func NewBearerTokenCredentialsProvider(bearerToken string) *BearerTokenCredentialsProvider { | ||
return &BearerTokenCredentialsProvider{ | ||
BearerToken: bearerToken, | ||
} | ||
} | ||
|
||
func (provider *BearerTokenCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
BearerToken: provider.BearerToken, | ||
} | ||
return | ||
} | ||
|
||
type RSAKeyPairCredentialsProvider struct { | ||
PublicKeyId string | ||
PrivateKeyId string | ||
sessionExpiration int | ||
} | ||
|
||
func NewRSAKeyPairCredentialsProvider(publicKeyId, privateKeyId string, sessionExpiration int) *RSAKeyPairCredentialsProvider { | ||
return &RSAKeyPairCredentialsProvider{ | ||
PublicKeyId: publicKeyId, | ||
PrivateKeyId: privateKeyId, | ||
sessionExpiration: sessionExpiration, | ||
} | ||
} | ||
|
||
func (provider *RSAKeyPairCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
// TODO: | ||
} | ||
return | ||
} | ||
|
||
type RAMRoleARNCredentialsProvider struct { | ||
credentialsProvider CredentialsProvider | ||
RoleArn string | ||
RoleSessionName string | ||
RoleSessionExpiration int | ||
Policy string | ||
StsRegion string | ||
ExternalId string | ||
} | ||
|
||
func NewRAMRoleARNCredentialsProvider(credentialsProvider CredentialsProvider, roleArn, roleSessionName string, roleSessionExpiration int, policy, stsRegion, externalId string) *RAMRoleARNCredentialsProvider { | ||
return &RAMRoleARNCredentialsProvider{ | ||
credentialsProvider: credentialsProvider, | ||
RoleArn: roleArn, | ||
RoleSessionName: roleSessionName, | ||
RoleSessionExpiration: roleSessionExpiration, | ||
Policy: policy, | ||
StsRegion: stsRegion, | ||
ExternalId: externalId, | ||
} | ||
} | ||
|
||
func (provider *RAMRoleARNCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
// TODO: | ||
} | ||
return | ||
} | ||
|
||
type ECSRAMRoleCredentialsProvider struct { | ||
RoleName string | ||
} | ||
|
||
func NewECSRAMRoleCredentialsProvider(roleName string) *ECSRAMRoleCredentialsProvider { | ||
return &ECSRAMRoleCredentialsProvider{ | ||
RoleName: roleName, | ||
} | ||
} | ||
|
||
func (provider *ECSRAMRoleCredentialsProvider) GetCredentials() (cc *Credentials, err error) { | ||
cc = &Credentials{ | ||
// TODO: | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.