1
0

sts.go 891 B

1234567891011121314151617181920212223242526272829303132333435
  1. package service
  2. import (
  3. "fmt"
  4. "aws-sts-mock/pkg/sigv4"
  5. "aws-sts-mock/pkg/sts"
  6. )
  7. // STSService handles STS business logic
  8. type STSService struct {
  9. // Add dependencies if needed (e.g., user store, role manager)
  10. }
  11. // NewSTSService creates a new STS service
  12. func NewSTSService() *STSService {
  13. return &STSService{}
  14. }
  15. // GetCallerIdentity returns the caller's identity information
  16. func (s *STSService) GetCallerIdentity(creds sigv4.AWSCredentials) (*sts.GetCallerIdentityResult, error) {
  17. return &sts.GetCallerIdentityResult{
  18. UserId: creds.AccountID,
  19. Account: creds.AccountID,
  20. Arn: fmt.Sprintf("arn:aws:iam::%s:root", creds.AccountID),
  21. }, nil
  22. }
  23. // ValidateAPIVersion checks if the API version is supported
  24. func (s *STSService) ValidateAPIVersion(version string) error {
  25. if version != "2011-06-15" {
  26. return fmt.Errorf("invalid API version: %s", version)
  27. }
  28. return nil
  29. }