Introduction | url-signer-go | Spatie       

 SPATIE  

url-signer-go
=============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Url-signer-go](https://spatie.be/docs/url-signer-go/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/url-signer-go/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/url-signer-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/url-signer-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/url-signer-go/v1/usage)
- [ Testing ](https://spatie.be/docs/url-signer-go/v1/testing)
- [ Changelog ](https://spatie.be/docs/url-signer-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/url-signer-go/v1/support-us)

  Url-signer-go 
===============

 Create signed URLs with a limited lifetime 

### Useful links

- [Repository](https://github.com/spatie/url-signer-go)
- [Discussions](https://github.com/spatie/url-signer-go/discussions)

Introduction
------------

This package can create URLs with a limited lifetime. This is done by adding an expiration date and a signature to the URL.

```
func signedLink(key, url string) (string, error) {
    return urlsigner.Sign(key, url, 30*time.Second)
}
```

Calling `signedLink(key, "https://myapp.com")` returns a URL that looks like `https://myapp.com?expires=xxxx&signature=xxxx`. Check the returned error before sharing it.

Imagine mailing this URL out to the users of your application. When a user clicks on a signed URL your application can validate it with:

```
func validLink(key, signedURL string) (bool, error) {
    signer, err := urlsigner.New(key)
    if err != nil {
        return false, err
    }
    return signer.Validate(signedURL), nil
}
```

Import `github.com/spatie/url-signer-go` and `time`. `Sign` accepts the same configuration callbacks as `New`. Keep the key in application configuration and keep a signer from `New` when signing or validating multiple links.

You can share signed links with applications using [spatie/url-signer](https://github.com/spatie/url-signer). See [usage](usage#url-normalization-and-shared-links) for URL normalization and the runtime settings needed for shared links.

Continue with [installation and setup](installation-and-setup).

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
