Email
Bize sorun

E-posta gönderin

[wpml_language_selector_widget]
[wpml_language_selector_widget]

Azure Key Vault

Azure Key Vault Nedir?

Azure Key Vault, Uygulamaların ve kullanıcıların secret yönetimini yapabılabilmesi için ortaya çıkmış bir servistir. Modern uygulamalarda genellikle, günümüz güncel saldırılarından ve açıklarından korunmak için uygulama içi secret tutulması önerilmiyor. Bunun için ise secretlerımızı yönetmek için bir Vault kullanmak mantıklı hale geliyor. Bu sayede yazılımı geliştiren kişilerin projeden ayrılması yada uygulama kaynak kodlarının ele geçirilmesi vb. Durumlarda bile güvenlik açığı olmuyor.

Azure Key Vault ile birlikte Secret, Key, ve Certificate yönetimi yapabiliyoruz. Uygulama içinde herhangi secretlerimiz için herhangi bir koruma algoritması geliştirmemize gerek kalmıyor bu sayede. Key vault servisi Authentication için Azure Active Directory (AAD) kullanmakta. Yetkilendirme için ise Rol Based Access Control (RBAC) kullanmakta. Bu sayede bir kullanıcıya bir secreti okuma yetkesi verebiliyoruz ama silme veya değiştirme yetkisi vermek zorunda kalmıyoruz. Bu yönetimin tabiki olmazsa olmazı bu servisin kullanım metriklerinede erişebiliyoruz. Azure Key Vault servisi bizim için hangi secret, key ne kadar kullanılmış nerelerden çağırılmış gibi metrikleri özetleyebiliyor. Bu logları istersek bir storage’a yazabilir istersek Azure monitörde dashboard haline getirebiliriz. Ayrıca Azure’un böyle bir servisinin olması diğer Azure servisleri ile entegre çalışması açısından bizim için büyük bir kolaylık sağlamakta. Tek bir onay ile birlikte diğer azure servisleriyle nasıl etkileşim içinde olacağını veya yetkilerini belirleyebiliyoruz.

Azure Key Vault Secrets

Key vaultumuzda genellikle secrets bölümü en çok kullanılan özellik olarak karşımıza çıkıyor. Secret olarak ise uygulamamızın connection stringleri, şifreleri veya tokenlarını barındabiliriz. Key vault secretleri şifreleri olarak saklar ve yönetir. Veri kayıt edildiği zaman Key Vault bu veriyi sekizli diziler (8 bit bayt) olarak saklar ve yönetir. Her biri maksimum 25k bayt boyutunda olur. Daha sonrasında bu secreti tekrar çağırabilmemiz için bize bir ID döndürür. Tabiki secretlerimizin güvenliğini arttırmak istersek Key Vault’un bu şifrelemesinin yanı sıra kendimizde uygulama içerisinden şifreli bir şekilde key vaulta göndererek güvenlik katmanımızı arttırabiliriz. Kullanıcı secret oluştururken isterse veri tipini belirtebilir. Bu veriyi çekerken ve yönetirken bizim için kolaylık sağlar.

Secret Özellikleri

Son Kullanım Tarihi(Expiration) : Bir secret oluştururken, bellir bir zamandan sonra bu secretin kullanımını kısıtlayabiliyoruz. Bu özellik default olarak sonsuza kadar erişilebilir olarak gelmekte.

Kullanım Zaman (Not Before) : Bir secreti oluşturduk ancak şuanda kimsenin kullanmasını istemiyorsanız bu özellik ile birlikte 1 hafta sonra kullanılabilir gibi bir kural koyabilirsiniz.

Erişilebilirlik : Bu özellik ile birlikte secret’iniz oluşturuldu, duruyor ancak kimsenin kullanmasını istemiyorsanız secret’ın erişilebilirliğini kısıtlayabilirsiniz.

Bunun yanı sıra secretin yaratılma tarihi ve değiştirilme tarihleri gibi parametreleride görüntüleyebiliyoruz.

Şifrelerimize Erişim Kontrolü

Azure Key Vault servisi için erişim kontrolü sadece o vault için sağlanır. Bunun anlamı X kişisine secret read yetkisi verirseniz tüm secretleri okuyabilir. Eğer bazı secretleri ayırmak istiyorsanız bunun için bu servisten birtane daha oluşturmanız gerekmekte. Genellikle burda senaryoya göre Key Vaultlar oluşturulması önerilir. Erişim Yetkileri : 

  • Get: Belirli bir secret’ı okuma
  • List: O key Vaultta tutulan tüm secretlerin bilgilerini getirme
  • Set: Secret Oluşturma
  • Delete: Secret Silme
  • Recover: Silinen bir secreti geri getirme
  • Backup: Key Vault’taki bir secretin yedeğini alma
  • Restore: Backup alınan bir secreti geri getirme

Key Vault Cheatsheet

Azure CLI’da kullanabileceğimiz Key Vault için bazı komutlar aşağıdaki gibidir :

Tüm Azure KV’leri listelemek = az keyvault list [–resource-group] [–subscription]

KV Silme = az keyvault delete –name

KV Yaratma = az keyvault create –name –resource-group –subscription –location –enable-soft-delete –tags

KV bilgileri getirme = az keyvault show –name –resource-group –subscription

Secret Bilgileri Getirme = az keyvault secret show –id –name –subscription –vault-name

Secretleri Listeleme = az keyvault secret list –vault-name

Silinen Bir Secretı Geri Getirme = az keyvault secret recover –id –name –subscription –vault-name

Secret Yaratma = az keyvault secret set –vault-name “<your-keyvault-name>” –name “MySecret” –value “Success!”

Secret Silme = az keyvault secret delete –id –name –subscripotion –vault-name

Key Bilgileri Getirme = az keyvault key show –id –name –subscription –vault-name

Keyleri Listeleme = az keyvault key list –vault-name

Key Recover Etme = az keyvault key recover –id –name –subscription –vault-name

Key Yaratma = az keyvault key create –name –vault-name

Key Silme = az keyvault key delete –id –name –subscripotion –vault-name

Key Vault Kullanım Örnekleri

Bir .Net Uygulamasında Key Vault’umuzdan bir secreti getirmek için istersek SDK kullanabilir istersek REST API çağırımlarını kullanabiliriz. SDK kullanım örneğinden kısaca bahsetmek gerekirse aşağıdaki 3 adet nuget pakedini uygulamamıza yükleyerek başlayabiliriz : 

Daha sonrasında ise Key Vaultumuza erişim için bir Service Accountu yaratıyoruz Azure Active Directory tarafında ve Service Account’umuzun bilgilerini environment variable olarak uygulamamızda belirliyoruz ;

Daha sonrasında ise controllerimizin içerisinde aşağıdaki gibi KV url’mizi oluşturuyoruz.

Bu adımdan sonra KV’miz için client’ımızı aşağıdaki gibi oluşturabiliriz ; 

Bu adımdan sonra ise istersek bir secret yaratabilir, istersek Vaultumuzdaki bir secreti aşağıdaki gibi uygulama içinde kullanabiliriz. 

Previous Post

Building a Workflow in Microsoft Teams with Azure Bot Service

Next Post

Azure Kullanılabilirlik Kümesi ve Kullanılabilirlik Alanı

What is Azure Key Vault?

Azure Key Vault is a service that has developed for applications and users to manage their secrets. In modern applications, it is generally not recommended to keep in-app secrets to protect against current attacks and vulnerabilities. So it makes sense to use a Vault to manage our secrets. In this way, people who develop the software leave the project or capture application source codes, etc. Even in situations, there is no vulnerability.

With Azure Key Vault, we can manage Secrets, Keys, and Certificates. In this way, we do not need to develop any protection algorithm for any of our secrets in the application. The key vault service uses Azure Active Directory (AAD) for Authentication. It uses Rol Based Access Control (RBAC) for authorization. In this way, we can authorize a user to read a secret, but we do not have to authorize to delete or change it. Azure Key Vault service can summarize metrics such as which secret, how much key is used and where it is called from. If we want to write these logs to a storage, we can turn them into dashboard on Azure monitor. In addition, Azure provides us a great convenience for us to work integrated with other Azure services. With a single confirmation, we can determine how it interacts or authorizes with other azure services.

Azure Key Vault Secrets

In our key vault, usually the secrets section is the most used feature. As Secret, we can contain connection strings, passwords or tokens of our application. Key vault secrets are stored and managed as passwords. When the data is saved, Key Vault stores and manages this data as octal arrays (8 bit bytes). Each is a maximum of 25k bytes in size. It then returns an ID to us so we can call this secret again. Of course, if we want to increase the security of our secrets, in addition to this encryption of Key Vault, we can increase our security layer by sending an encrypted key vault within the application. The user can specify the data type when creating a secret. It provides convenience for us when capturing and managing this data.

Secret Properties

Expiration Date : While creating a secret, we can restrict the use of this secret after a certain time. This feature comes accessible forever by default.

Not Before : We created a secret, but if you don’t want anyone to use it right now, you can set a rule with this feature that can be used after 1 week.

Accessable : With this feature, your secret has been created, but you can restrict the accessibility of the secret if you do not want anyone to use it.

In addition, we can display parameters such as the creation date of the secret and the modified dates.

Secrets Access Control

Access control for the Azure Key Vault service is provided only for that vault. This means if you authorize X to read secrets, they can read all secrets. If you want to separate some secrets, you have to create another one for this service. It is generally recommended to create Key Vaults according to the scenario here. Access Rights:

    • Get: Reading a specific secret
    • List: Bringing information to all secrets held in that key Vault
    • Set: Create a secret
    • Delete: Delete a secret
    • Recover: Bring back a deleted secret
    • Backup: Backing up a secret in Key Vault
    • Restore: Bringing back a backup secret

Key Vault Cheatsheet

Some commands for Key Vault that we can use in Azure CLI are as follows:

List All Azure Key Vaults = az keyvault list [–resource-group] [–subscription]

KV Deletion = az keyvault delete –name

KV Creation = az keyvault create –name –resource-group –subscription –location –enable-soft-delete –tags

KV Feth Information = az keyvault show –name –resource-group –subscription

Secret Fetch Information = az keyvault secret show –id –name –subscription –vault-name

Secrets List = az keyvault secret list –vault-name

Recovering a Deleted Secret = az keyvault secret recover –id –name –subscription –vault-name

Secret Creation = az keyvault secret set –vault-name “<your-keyvault-name>” –name “MySecret” –value “Success!”

Secret Deletion = az keyvault secret delete –id –name –subscripotion –vault-name

Fetch Key Info = az keyvault key show –id –name –subscription –vault-name

List Keys= az keyvault key list –vault-name

Recover Key = az keyvault key recover –id –name –subscription –vault-name

Key Creation = az keyvault key create –name –vault-name

Key Deletion = az keyvault key delete –id –name –subscripotion –vault-name

Key Vault Usage Scenarious

In a .Net Application we can use the SDK if we want to bring a secret from our Key Vault, or use the REST API calls if we want. To briefly mention the SDK usage example, we can start by installing the following 3 nuget packages in our application:

Then we create a Service Account to access our Key Vault in Azure Active Directory and we determine the information of our Service Account as environment variable in our application;

Then, we create our KV url in our controller as follows.

After this step, we can create our client for our KV as follows;

After this step, we can create a secret if we want. If we want, we can use a secret in our Vault in the application as below.

Previous Post

Building a Workflow in Microsoft Teams with Azure Bot Service

Next Post

Azure Kullanılabilirlik Kümesi ve Kullanılabilirlik Alanı

YEPYENİ BİR DENEYİM İÇİN

Bizimle İletişime Geçin

Teknoloji sorunları hakkında endişelenmeyi bırakın. Sadece işinize odaklanın. İhtiyacınız olan teknolojiyi sizin için belirleyip, yönetelim.
Start typing to see you are looking for.
Çerez Bilgilendirmesi
Sitemizde kullanımı analiz etmek, içerik ve reklamları kişiselleştirmek, reklam kampanyalarının etkinliğini ölçmek ve ziyaret tercihlerinizi hatırlamak için çerezler kullanmaktayız. Çerezler hakkında detaylı bilgi için buraya tıklayın.
Accept