iap

package
v1.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthenticatedUserId is IAP User ID Header Key
	AuthenticatedUserIDKey = "X-Goog-Authenticated-User-Id"

	// AuthenticatedUserEmail is IAP User Email Header Key
	AuthenticatedUserEmailKey = "X-Goog-Authenticated-User-Email"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	ID    string
	Email string
}

User is IAPを通してログインしているUser

note: Every user has the same user ID for all App Engine applications. If your app uses the user ID in public data, such as by including it in a URL parameter, you should use a hash algorithm with a "salt" value added to obscure the ID. Exposing raw IDs could allow someone to associate a user's activity in one app with that in another, or get the user's email address by coercing the user to sign in to another app.

func CurrentUser

func CurrentUser(ctx context.Context) *User

CurrentUser is context からUserを取得する

先に WithContextValue() でセットされていることが前提

func CurrentUserWithContext

func CurrentUserWithContext(ctx context.Context, r *http.Request) (context.Context, *User)

CurrentUserWithContext is IAPを通してログインしているUserを取得する

accounts.google.com:XXXXXX という値が入っているはずなので、後ろ側の部分を取って設定している https://cloud.google.com/iap/docs/identity-howto?hl=en#getting_the_users_identity_with_signed_headers

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService is App Engine User Serviceっぽいものを実装している

func NewUserService

func NewUserService(ctx context.Context, crmService *crmbox.ResourceManagerService) (*UserService, error)

NewUserService is return UserService

func (*UserService) IsAdmin

func (s *UserService) IsAdmin(ctx context.Context) (bool, error)

IsAdmin is App Engine User ServiceのようにProjectの権限を持っているかどうかを返す Cloud Resource Manager Serviceを利用して、実行ProjectのIAMを見るので、実行するクライアントがIAMを閲覧できる権限を持っている必要がある。 inherited されてる 権限は見ていない context に login userが含まれていない場合は、false を返す

need resourcemanager.projects.getIamPolicy resourcemanager.projects.getIamPolicy を持っている規定済みIAMは以下辺り https://cloud.google.com/iam/docs/understanding-roles?hl=en#primitive_roles https://cloud.google.com/iam/docs/understanding-roles?hl=en#resource-manager-roles https://cloud.google.com/iam/docs/understanding-roles?hl=en#project-roles

func (*UserService) IsAdminTargetUser

func (s *UserService) IsAdminTargetUser(ctx context.Context, u *User) (bool, error)

IsAdminTargetUser is App Engine User ServiceのようにProjectの権限を持っているかどうかを返す Cloud Resource Manager Serviceを利用して、実行ProjectのIAMを見るので、実行するクライアントがIAMを閲覧できる権限を持っている必要がある。 inherited されてる 権限は見ていない

need resourcemanager.projects.getIamPolicy resourcemanager.projects.getIamPolicy を持っている規定済みIAMは以下辺り https://cloud.google.com/iam/docs/understanding-roles?hl=en#primitive_roles https://cloud.google.com/iam/docs/understanding-roles?hl=en#resource-manager-roles https://cloud.google.com/iam/docs/understanding-roles?hl=en#project-roles

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL