<commit_before>/*
Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package auth

import (
	"fmt"

	"github.com/gravitational/teleport"

	"github.com/gravitational/trace"
)

// PermissionChecker interface verifies that clients have permissions
// to execute any action of the auth server
type PermissionChecker interface {
	// HasPermission checks if the given role has a permission to execute
	// the action
	HasPermission(role teleport.Role, action string) error
}

// NewStandardPermissions returns permission checker with hardcoded roles
// that are built in when auth server starts in standard mode
func NewStandardPermissions() PermissionChecker {
	sp := standardPermissions{}
	sp.permissions = make(map[teleport.Role](map[string]bool))

	sp.permissions[teleport.RoleUser] = map[string]bool{
		ActionSignIn:             true,
		ActionCreateWebSession:   true,
		ActionGenerateUserCert:   true,
		ActionGetCertAuthorities: true,
		ActionGetSession:         true,
		ActionGetSessions:        true,
		ActionGetEvents:          true,
	}

	sp.permissions[teleport.RoleProvisionToken] = map[string]bool{
		ActionRegisterUsingToken:    true,
		ActionRegisterNewAuthServer: true,
	}

	sp.permissions[teleport.RoleNode] = map[string]bool{
		ActionUpsertServer:       true,
		ActionGetCertAuthorities: true,
		ActionGetLocalDomain:     true,
		ActionGetUserKeys:        true,
		ActionGetServers:         true,
		ActionUpsertParty:        true,
		ActionLogEntry:           true,
		ActionGetChunkWriter:     true,
	}

	sp.permissions[teleport.RoleWeb] = map[string]bool{
		//ActionSignIn:           true,
		ActionCreateWebSession: true,
		ActionGetWebSession:    true,
		ActionDeleteWebSession: true,
		ActionGetSession:       true,
		ActionGetSessions:      true,
		ActionGetEvents:        true,
	}

	sp.permissions[teleport.RoleSignup] = map[string]bool{
		ActionGetSignupTokenData:  true,
		ActionCreateUserWithToken: true,
	}

	return &sp
}
<commit_msg>Deleted comented code<commit_after>/*
Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package auth

import (
	"fmt"

	"github.com/gravitational/teleport"

	"github.com/gravitational/trace"
)

// PermissionChecker interface verifies that clients have permissions
// to execute any action of the auth server
type PermissionChecker interface {
	// HasPermission checks if the given role has a permission to execute
	// the action
	HasPermission(role teleport.Role, action string) error
}

// NewStandardPermissions returns permission checker with hardcoded roles
// that are built in when auth server starts in standard mode
func NewStandardPermissions() PermissionChecker {
	sp := standardPermissions{}
	sp.permissions = make(map[teleport.Role](map[string]bool))

	sp.permissions[teleport.RoleUser] = map[string]bool{
		ActionSignIn:             true,
		ActionCreateWebSession:   true,
		ActionGenerateUserCert:   true,
		ActionGetCertAuthorities: true,
		ActionGetSession:         true,
		ActionGetSessions:        true,
		ActionGetEvents:          true,
	}

	sp.permissions[teleport.RoleProvisionToken] = map[string]bool{
		ActionRegisterUsingToken:    true,
		ActionRegisterNewAuthServer: true,
	}

	sp.permissions[teleport.RoleNode] = map[string]bool{
		ActionUpsertServer:       true,
		ActionGetCertAuthorities: true,
		ActionGetLocalDomain:     true,
		ActionGetUserKeys:        true,
		ActionGetServers:         true,
		ActionUpsertParty:        true,
		ActionLogEntry:           true,
		ActionGetChunkWriter:     true,
	}

	sp.permissions[teleport.RoleWeb] = map[string]bool{
		ActionCreateWebSession: true,
		ActionGetWebSession:    true,
		ActionDeleteWebSession: true,
		ActionGetSession:       true,
		ActionGetSessions:      true,
		ActionGetEvents:        true,
	}

	sp.permissions[teleport.RoleSignup] = map[string]bool{
		ActionGetSignupTokenData:  true,
		ActionCreateUserWithToken: true,
	}

	return &sp
}

{'fraction_non_alphanumeric': 0.07422512234910278, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 3.989827060020346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5360006', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1396, 'n_words': 428}